From 408dc7358bb13f322680b3e70dfb021cf4a5f73e Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Fri, 20 May 2011 12:15:50 +0000 Subject: [PATCH] Clear markers on new route, show boundaries of map data when run on map.project-osrm.org, route is always recalculated on drag completion --- Docs/WebFrontend/Map.js | 36 +++++++++++++++++++++++++++++++++--- Docs/WebFrontend/Route.js | 2 +- Docs/WebFrontend/index.html | 2 +- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/Docs/WebFrontend/Map.js b/Docs/WebFrontend/Map.js index 9854f6fe9..04f2ef5f1 100644 --- a/Docs/WebFrontend/Map.js +++ b/Docs/WebFrontend/Map.js @@ -60,7 +60,37 @@ function init(){ projection: new OpenLayers.Projection("EPSG:900913"), displayProjection: new OpenLayers.Projection("EPSG:4326") } ); - //Add the base layers. + //Add the base layers. + + var coverageLayer = new OpenLayers.Layer.Vector("Coverage", { + style: { + strokeColor: "#000000", + strokeTransparency: 0.5, + strokeWidth: 4 + } + }); + if("map.project-osrm.org" == location.host) { + var coveragePointList = [ + new OpenLayers.Geometry.Point(-11.99, 58.80), + new OpenLayers.Geometry.Point(-11.99, 35.30), + new OpenLayers.Geometry.Point(-7.57, 35.30), + new OpenLayers.Geometry.Point(9.22, 38.24), + new OpenLayers.Geometry.Point(15.38, 35.39), + new OpenLayers.Geometry.Point(18.92, 40.02), + new OpenLayers.Geometry.Point(15.70, 42.25), + new OpenLayers.Geometry.Point(15.70, 55.40), + new OpenLayers.Geometry.Point(30.31, 60.29), + new OpenLayers.Geometry.Point(30.31, 71.27), + new OpenLayers.Geometry.Point(21.01, 71.27), + new OpenLayers.Geometry.Point(-11.99, 58.80) + ]; + + var line_string = new OpenLayers.Geometry.LineString(coveragePointList).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); + coverageLayer.addFeatures([new OpenLayers.Feature.Vector(line_string)]); + + map.addLayer(coverageLayer); + } + map.addLayer(new OpenLayers.Layer.OSM.Mapnik("Mapnik")); map.addLayer(new OpenLayers.Layer.OSM.MapQuest("MapQuest")); map.addLayer(new OpenLayers.Layer.OSM.Osmarender("Osmarender")); @@ -109,9 +139,9 @@ function init(){ if(!ISCALCULATING){ routing(true); }}, onComplete: function(feature, pixel){ feature.move(map.getLonLatFromPixel(pixel)); - if(!ISCALCULATING){ routing(false); }}, + routing(false); }, onLeave: function(f){ - alert("here"); + alert("here"); if(!ISCALCULATING){ routing(false); }} }); map.addControl(dragFeatures); diff --git a/Docs/WebFrontend/Route.js b/Docs/WebFrontend/Route.js index 631bd461a..1fafede54 100644 --- a/Docs/WebFrontend/Route.js +++ b/Docs/WebFrontend/Route.js @@ -98,6 +98,7 @@ function reroute() { function showResultsDragRoute(response) {    if (response) {     //Display Route     showRouteGeometry(response);    } +   markersLayer.clearMarkers();    ISCALCULATING = false; } @@ -113,7 +114,6 @@ function showResultsRoute(response) { showRouteGeometry(response); }     -            //Show Route Summary        var output = '

Some information about your Way
from \''+response.route_summary.start_point+'\' to \''+response.route_summary.end_point+'\'

';        output += '

Distance: '+response.route_summary.total_distance/1000+' km - Duration: '+secondsToTime(response.route_summary.total_time)+'

Your Route-Instructions:

'; diff --git a/Docs/WebFrontend/index.html b/Docs/WebFrontend/index.html index 9f2666fb9..5d4c8a32d 100644 --- a/Docs/WebFrontend/index.html +++ b/Docs/WebFrontend/index.html @@ -52,7 +52,7 @@
Options -
+

Demo Website for the
Open Source Routing Machine Project