Clear markers on new route, show boundaries of map data when run on map.project-osrm.org, route is always recalculated on drag completion
This commit is contained in:
parent
ff5ac3a109
commit
408dc7358b
@ -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);
|
||||
|
@ -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 = '<p class="routeSummaryHL">Some information about your Way <br> from \'<span class="routeSummaryHLlight">'+response.route_summary.start_point+'</span>\' to \'<span class="routeSummaryHLlight">'+response.route_summary.end_point+'</span>\'</p>';
|
||||
output += '<p class="routeSummary">Distance: <span class="routeSummarybold">'+response.route_summary.total_distance/1000+' km</span> - Duration: <span class="routeSummarybold">'+secondsToTime(response.route_summary.total_time)+'</span></p><p class="routeInstructionsHL"> Your Route-Instructions:</p>';
|
||||
|
@ -52,7 +52,7 @@
|
||||
|
||||
<div id="calc_route" class="calc_route"><span class="options"><a href="#" onclick="closeOpenDiv('options');">Options</a></span>
|
||||
<select name="selectRoutePref" id="selectRoutePref" title="Select the route preference ..."><option value="Fastest" selected>Car (travel time)</option></select>
|
||||
<input name="Submit5" type="submit" class="calculate_button" id="Calculate" title="Route!" onClick="routing(false);" value="Route!"></div>
|
||||
<input name="Submit5" type="submit" class="calculate_button" id="Calculate" title="Route!" onClick="markersLayer.clearMarkers(); routing(false);" value="Route!"></div>
|
||||
|
||||
<div id="options" class="options_div" style="display:none"><input class="checkbox" type="checkbox" name="cbNoNames" id="cbNoNames" value="checkbox">Highlight No Name Streets in my Route</div>
|
||||
<div id="information" class="information"> <p class="infoHL">Demo Website for the <br><a target="_blank" href="http://project-osrm.org/">Open Source Routing Machine Project</a></p> </div>
|
||||
|
Loading…
Reference in New Issue
Block a user