/* This program is free software; you can redistribute it and/or modify it under the terms of the GNU AFFERO General Public License as published by the Free Software Foundation; either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or see http://www.gnu.org/licenses/agpl.txt. */ // OSRM markers // [base marker class, derived highlight marker and route marker classes] // base marker class (wraps Leaflet markers) OSRM.Marker = function( label, style, position ) { this.label = label ? label : "marker"; this.position = position ? position : new L.LatLng(0,0); this.marker = new L.MouseMarker( this.position, style ); this.marker.parent = this; this.shown = false; this.hint = null; }; OSRM.extend( OSRM.Marker,{ show: function() { OSRM.G.map.addLayer(this.marker); this.shown = true; }, hide: function() { OSRM.G.map.removeLayer(this.marker); this.shown = false; }, setPosition: function( position ) { this.position = position; this.marker.setLatLng( position ); this.hint = null; }, getPosition: function() { return this.position; }, getLat: function() { return this.position.lat; }, getLng: function() { return this.position.lng; }, isShown: function() { return this.shown; }, centerView: function(zoom) { if( zoom == undefined ) zoom = OSRM.DEFAULTS.ZOOM_LEVEL; OSRM.G.map.setViewUI( this.position, zoom ); }, toString: function() { return "OSRM.Marker: \""+this.label+"\", "+this.position+")"; } }); // route marker class (draggable, invokes route drawing routines) OSRM.RouteMarker = function ( label, style, position ) { style.baseicon = style.icon; OSRM.RouteMarker.prototype.base.constructor.apply( this, arguments ); this.label = label ? label : "route_marker"; this.marker.on( 'click', this.onClick ); this.marker.on( 'drag', this.onDrag ); this.marker.on( 'dragstart', this.onDragStart ); this.marker.on( 'dragend', this.onDragEnd ); }; OSRM.inheritFrom( OSRM.RouteMarker, OSRM.Marker ); OSRM.extend( OSRM.RouteMarker, { onClick: function(e) { for( var i=0; i1) OSRM.Routing.getRoute_Dragging(); OSRM.Geocoder.updateLocation( this.parent.label ); }, onDragStart: function(e) { OSRM.G.dragging = true; this.switchIcon(this.options.dragicon); // store id of dragged marker for( var i=0; i