summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--resources/leaflet-route/leaflet-route.js16
-rw-r--r--src/leaflet-soton.js7
2 files changed, 22 insertions, 1 deletions
diff --git a/resources/leaflet-route/leaflet-route.js b/resources/leaflet-route/leaflet-route.js
index 6d820a9..c2ac129 100644
--- a/resources/leaflet-route/leaflet-route.js
+++ b/resources/leaflet-route/leaflet-route.js
@@ -96,6 +96,8 @@ L.Route = L.FeatureGroup.extend({
highlightRoute: function(id) {
var layer = this._routeLayers[id];
+ layer._lrHighlighted = true;
+
layer.setStyle({
weight: 10,
opacity: 1,
@@ -112,9 +114,23 @@ L.Route = L.FeatureGroup.extend({
layer.bringToFront();
},
+ toggleRouteHighlight: function(id) {
+ if (this.isRouteHighlighed(id)) {
+ this.resetRoute(id);
+ } else {
+ this.highlightRoute(id);
+ }
+ },
+ isRouteHighlighted: function(id) {
+ var layer = this._routeLayers[id];
+
+ return layer._lrHighlighted === true;
+ },
resetRoute: function(id) {
var layer = this._routeLayers[id];
+ layer._lrHighlighted = false;
+
this._routeLayer.resetStyle(layer);
layer.setText(null);
diff --git a/src/leaflet-soton.js b/src/leaflet-soton.js
index 380249b..0be755b 100644
--- a/src/leaflet-soton.js
+++ b/src/leaflet-soton.js
@@ -654,8 +654,13 @@ SELECT * WHERE {\
var a = L.Control.Route.createRouteLink(routesInfo[name], (function(name) {
return function() {
+ var wasHighlighted = routeLayer.isRouteHighlighted(name);
+
routeLayer.resetRoutes();
- routeLayer.highlightRoute(name);
+
+ if (!wasHighlighted) {
+ routeLayer.highlightRoute(name);
+ }
};
})(routesInfo[name].properties.name));