Skip to content
Snippets Groups Projects
Commit 9262b07c authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

you can now hide alternative routes

parent a8ae4f72
No related branches found
No related tags found
No related merge requests found
...@@ -320,7 +320,9 @@ Route.prototype.printRoute = function () { ...@@ -320,7 +320,9 @@ Route.prototype.printRoute = function () {
var altRouteColor = "#797979"; var altRouteColor = "#797979";
var altRouteHoverColor = "#FF0000"; var altRouteHoverColor = "#FF0000";
for (var i = 0; i < this.route.routes.length; i++) { for (var i = 0; i < this.route.routes.length; i++) {
if (i == this.route.activeRoute) continue; if (i == this.route.activeRoute ||
(typeof this.route.routes[i]["available"] == "boolean" && !this.route.routes[i]["available"]))
continue;
var altgeojson = this.route.routes[i].geometry; var altgeojson = this.route.routes[i].geometry;
this.interactiveMap.map.addLayer({ this.interactiveMap.map.addLayer({
'id': 'alt-route-' + i, 'id': 'alt-route-' + i,
...@@ -352,7 +354,7 @@ Route.prototype.printRoute = function () { ...@@ -352,7 +354,7 @@ Route.prototype.printRoute = function () {
var timeString = this.durationString(time); var timeString = this.durationString(time);
var popup = $( var popup = $(
'\ '\
<div id="popup-alt-route-' + i + '" class="ol-popup alternative-route" title="Klicken zum Auswählen der Alternativroute.">\ <div id="popup-alt-route-' + i + '" class="ol-popup alternative-route" data-index="' + i + '" title="Klicken zum Auswählen der Alternativroute.">\
<div id="popup-content">\ <div id="popup-content">\
<font color="' + <font color="' +
(time > 0 ? "red" : "green") + (time > 0 ? "red" : "green") +
...@@ -365,13 +367,20 @@ Route.prototype.printRoute = function () { ...@@ -365,13 +367,20 @@ Route.prototype.printRoute = function () {
</div>\ </div>\
</div>" </div>"
).get(0).outerHTML; ).get(0).outerHTML;
this.informationOverlays.push(new mapboxgl.Popup({ var tmppopup = new mapboxgl.Popup({
'closeButton': false, 'closeButton': true,
'closeOnClick': false 'closeOnClick': false
}) })
.setLngLat(pos) .setLngLat(pos)
.setHTML(popup) .setHTML(popup)
.addTo(this.interactiveMap.map)); .addTo(this.interactiveMap.map);
this.informationOverlays.push(tmppopup);
var caller = this;
tmppopup.once('close', function (event) {
var tmpI = $($(this)[0]._content).find(".alternative-route").attr("data-index")
caller.route.routes[tmpI]["available"] = false;
caller.printRoute();
});
$("#popup-alt-route-" + i).mouseover({ caller: this, index: i }, function (event) { $("#popup-alt-route-" + i).mouseover({ caller: this, index: i }, function (event) {
event.data.caller.interactiveMap.map.setPaintProperty("alt-route-" + event.data.index, "line-color", altRouteHoverColor); event.data.caller.interactiveMap.map.setPaintProperty("alt-route-" + event.data.index, "line-color", altRouteHoverColor);
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment