summaryrefslogtreecommitdiff
path: root/resources
diff options
context:
space:
mode:
authorChristopher Baines <cb15g11@soton.ac.uk>2015-03-21 12:34:11 +0000
committerChristopher Baines <cb15g11@soton.ac.uk>2015-03-21 12:34:11 +0000
commitfc567391a5420d84ccb1004dc37cbfae3f60a01e (patch)
tree343b7494f6d779acfc964d718a2587702a5e35a7 /resources
parent255e2e3a55f59e40397bde2ed3cc387bc07a6836 (diff)
downloadleaflet-soton-fc567391a5420d84ccb1004dc37cbfae3f60a01e.tar
leaflet-soton-fc567391a5420d84ccb1004dc37cbfae3f60a01e.tar.gz
Allow for toggling which routes are highlighted
Diffstat (limited to 'resources')
-rw-r--r--resources/leaflet-route/leaflet-route.js16
1 files changed, 16 insertions, 0 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);