fixed bug when selecting city options in geocoder,
added clicking on map to create markers, reset also clears input boxes now
This commit is contained in:
		
							parent
							
								
									784f417857
								
							
						
					
					
						commit
						4918549bac
					
				@ -39,8 +39,11 @@ getLng: function() {
 | 
			
		||||
isShown: function() {
 | 
			
		||||
	return this.shown;
 | 
			
		||||
},
 | 
			
		||||
centerView: function() {
 | 
			
		||||
	map.setView( new L.LatLng( this.position.lat, this.position.lng-0.02), OSRM.DEFAULTS.ZOOM_LEVEL);		// dirty hack
 | 
			
		||||
centerView: function(zooming) {
 | 
			
		||||
	var zoom = OSRM.DEFAULTS.ZOOM_LEVEL;
 | 
			
		||||
	if( zooming == false )
 | 
			
		||||
		zoom = map.getZoom();
 | 
			
		||||
	map.setView( new L.LatLng( this.position.lat, this.position.lng-0.02), zoom);		// dirty hack
 | 
			
		||||
},
 | 
			
		||||
toString: function() {
 | 
			
		||||
	return "OSRM.Marker: \""+this.label+"\", "+this.position+")";
 | 
			
		||||
 | 
			
		||||
@ -57,7 +57,7 @@ function showGeocoderResults(marker_id, response) {
 | 
			
		||||
			html += '<td class="result-items">';
 | 
			
		||||
 | 
			
		||||
			if(result.display_name){
 | 
			
		||||
				html += '<div class="result-item" onclick="onclickGeocoderResult('+marker_id+', '+result.lat+', '+result.lon+');">'+result.display_name+'</div>';
 | 
			
		||||
				html += '<div class="result-item" onclick="onclickGeocoderResult(\''+marker_id+'\', '+result.lat+', '+result.lon+');">'+result.display_name+'</div>';
 | 
			
		||||
			}
 | 
			
		||||
			html += "</td></tr>";
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -122,7 +122,21 @@ function initMap() {
 | 
			
		||||
	map.setView( new L.LatLng( OSRM.DEFAULTS.ONLOAD_LATITUDE, OSRM.DEFAULTS.ONLOAD_LONGITUDE-0.02), OSRM.DEFAULTS.ZOOM_LEVEL);
 | 
			
		||||
	map.on('zoomend', function(e) { getRoute(OSRM.FULL_DESCRIPTION); });	
 | 
			
		||||
 | 
			
		||||
	// onmousemove test	
 | 
			
		||||
	map.on('click', function(e) {
 | 
			
		||||
		if( !my_markers.route[0] || my_markers.route[0].label != OSRM.SOURCE_MARKER_LABEL) {
 | 
			
		||||
			index = my_markers.setSource( e.latlng );
 | 
			
		||||
			my_markers.route[index].show();
 | 
			
		||||
			my_markers.route[index].centerView(false);	
 | 
			
		||||
			getRoute(OSRM.FULL_DESCRIPTION);		
 | 
			
		||||
		}
 | 
			
		||||
		else if( !my_markers.route[my_markers.route.length-1] || my_markers.route[ my_markers.route.length-1 ].label != OSRM.TARGET_MARKER_LABEL) {
 | 
			
		||||
			index = my_markers.setTarget( e.latlng );
 | 
			
		||||
			my_markers.route[index].show();
 | 
			
		||||
			my_markers.route[index].centerView(false);	
 | 
			
		||||
			getRoute(OSRM.FULL_DESCRIPTION);		
 | 
			
		||||
		}		
 | 
			
		||||
	} );
 | 
			
		||||
	// onmousemove test
 | 
			
		||||
//	map.on('mousemove', function(e) { console.log("pos: " + e.latlng); });
 | 
			
		||||
//	map.on('mousemove', function(e) {
 | 
			
		||||
//		var objs = new Array;
 | 
			
		||||
 | 
			
		||||
@ -130,6 +130,7 @@ function showRouteDescription(response) {
 | 
			
		||||
 						
 | 
			
		||||
	// create link to the route
 | 
			
		||||
	var route_link ='<span class="route-summary" id="route-link">[<a id="gpx-link" href="#" onclick="onClickCreateShortcut(\'' + OSRM.DEFAULTS.WEBSITE_URL + query_string + '\')">'+OSRM.loc("GET_LINK")+'</a>]</span>';
 | 
			
		||||
	//var route_link ='<span class="route-summary" id="route-link">[<a id="gpx-link" href="#" onclick="onClickCreateShortcut(\'' + document.URL + query_string + '\')">'+OSRM.loc("GET_LINK")+'</a>]</span>';
 | 
			
		||||
 | 
			
		||||
	// create GPX link
 | 
			
		||||
	var gpx_link = '<span class="route-summary">[<a id="gpx-link" href="' + OSRM.DEFAULTS.HOST_ROUTING_URL + query_string + '&output=gpx">'+OSRM.loc("GPX_FILE")+'</a>]</span>';
 | 
			
		||||
@ -308,8 +309,8 @@ function startRouting() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function resetRouting() {
 | 
			
		||||
	//document.getElementById('input-source-name').value = "";
 | 
			
		||||
	//document.getElementById('input-target-name').value = "";
 | 
			
		||||
	document.getElementById('input-source-name').value = "";
 | 
			
		||||
	document.getElementById('input-target-name').value = "";
 | 
			
		||||
	
 | 
			
		||||
	my_route.hideRoute();
 | 
			
		||||
	my_markers.removeAll();
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user