From 3c67959ced37b920ac95b0a16b45fb49e53a16a3 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 3 Mar 2015 22:30:17 +0000 Subject: Move the route layer to the bottom Change the order in which the layers are added to the map, this means that the route layer sits lower down. --- src/leaflet-soton.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/leaflet-soton.js b/src/leaflet-soton.js index 4488f1a..4fe2a2e 100644 --- a/src/leaflet-soton.js +++ b/src/leaflet-soton.js @@ -864,7 +864,7 @@ SELECT * WHERE {\ }; } - layers[layerName] = L.geoJson(emptyFeatureCollection, layerOptions).addTo(map); + layers[layerName] = L.geoJson(emptyFeatureCollection, layerOptions); }); this.on('zoomend', function(e) { @@ -885,13 +885,11 @@ SELECT * WHERE {\ }); LS.getData(function(data) { - for (var layerName in layers) { - var layer = layers[layerName]; - - layer.clearLayers(); - layer.addData(data[layerName]); - } + // if there is a route layer, deal with it first, as it wants + // to be added before the other layers, such that it appears + // underneath them (and thus has less priority in user + // interactions) if ("Route" in L) { var routeLayer = map.routeLayer = new L.Route(options.busRoutes ? data.busRoutes : emptyFeatureCollection, data.busStops, { routeOptions: { @@ -939,6 +937,15 @@ SELECT * WHERE {\ } } + for (var layerName in layers) { + var layer = layers[layerName]; + + layer.clearLayers(); + layer.addData(data[layerName]); + + layer.addTo(map); + } + LS.getWorkstationData(function(workstationData) { if (options.indoor) { -- cgit v1.2.3