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:
DennisSchiefer 2012-03-13 15:26:53 +01:00
parent 784f417857
commit 4918549bac
4 changed files with 24 additions and 6 deletions

View File

@ -39,8 +39,11 @@ getLng: function() {
isShown: function() { isShown: function() {
return this.shown; return this.shown;
}, },
centerView: function() { centerView: function(zooming) {
map.setView( new L.LatLng( this.position.lat, this.position.lng-0.02), OSRM.DEFAULTS.ZOOM_LEVEL); // dirty hack 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() { toString: function() {
return "OSRM.Marker: \""+this.label+"\", "+this.position+")"; return "OSRM.Marker: \""+this.label+"\", "+this.position+")";

View File

@ -57,7 +57,7 @@ function showGeocoderResults(marker_id, response) {
html += '<td class="result-items">'; html += '<td class="result-items">';
if(result.display_name){ 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>"; html += "</td></tr>";
} }

View File

@ -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.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); }); 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) { console.log("pos: " + e.latlng); });
// map.on('mousemove', function(e) { // map.on('mousemove', function(e) {
// var objs = new Array; // var objs = new Array;

View File

@ -130,6 +130,7 @@ function showRouteDescription(response) {
// create link to the route // 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(\'' + 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 // 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>'; 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() { function resetRouting() {
//document.getElementById('input-source-name').value = ""; document.getElementById('input-source-name').value = "";
//document.getElementById('input-target-name').value = ""; document.getElementById('input-target-name').value = "";
my_route.hideRoute(); my_route.hideRoute();
my_markers.removeAll(); my_markers.removeAll();