summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristopher Baines <cb15g11@soton.ac.uk>2015-03-03 21:59:00 +0000
committerChristopher Baines <cb15g11@soton.ac.uk>2015-03-03 21:59:00 +0000
commit11b86a6d8ab226a55fcd2e69c40989ebc2461853 (patch)
tree2fe5159c7184af186fdbbe44c872513f0a0adbfc /src
parent59f5f9f361152dca105db2954137b5bfa77d7c2b (diff)
downloadleaflet-soton-11b86a6d8ab226a55fcd2e69c40989ebc2461853.tar
leaflet-soton-11b86a6d8ab226a55fcd2e69c40989ebc2461853.tar.gz
Route improvements
Work towards making the route parts an independant plugin. Also make several other improvements in the process.
Diffstat (limited to 'src')
-rw-r--r--src/leaflet-soton.js36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/leaflet-soton.js b/src/leaflet-soton.js
index 3edb8ba..4488f1a 100644
--- a/src/leaflet-soton.js
+++ b/src/leaflet-soton.js
@@ -548,20 +548,32 @@ SELECT * WHERE {\
content.appendChild(table);
});
},
- busStop: function(properties) {
+ busStop: function(properties, routeLayer) {
return getTemplateWrapper(properties, function(content) {
- var routeList = document.createElement("ul");
- routeList.className = "ls-route-list";
+ var routesList = [];
+ var routeMasters = routeLayer.getRouteMasters();
- properties.routes.forEach(function(route) {
- var routeLi = document.createElement("li");
- routeLi.textContent = route;
+ for (var routeMasterName in routeMasters) {
+ var routeMaster = routeMasters[routeMasterName];
- routeList.appendChild(routeLi);
+ for (var i in routeMaster.routes) {
+ var route = routeMaster.routes[i];
+
+ if (properties.routes.indexOf(route.properties.ref) !== -1) {
+ routesList.push(route);
+ }
+ }
+ }
+
+ var routeListControl = L.Control.Route.createRouteList({
+ routes: routesList
+ }, function(routeName) {
+ routeLayer.resetRoutes();
+ routeLayer.highlightRoute(routeName);
});
- content.appendChild(routeList);
+ content.appendChild(routeListControl);
var IFrame = document.createElement('iframe');
IFrame.setAttribute('src', 'http://bus.southampton.ac.uk/bus-stop-iframe/' + properties.uri.slice(37) + ".html")
@@ -885,7 +897,7 @@ SELECT * WHERE {\
routeOptions: {
onEachFeature: function(feature, layer) {
layer.on('click', function(e) {
- var content = busRouteTemplate(feature.properties);
+ var content = LS.infoTemplates.busRoute(feature.properties, routeLayer);
map.showInfo(content, e.latlng);
});
@@ -895,7 +907,7 @@ SELECT * WHERE {\
stopOptions: {
onEachFeature: function(feature, layer) {
layer.on('click', function(e) {
- var content = LS.infoTemplates.busStop(feature.properties);
+ var content = LS.infoTemplates.busStop(feature.properties, routeLayer);
map.showInfo(content, e.latlng);
});
@@ -905,7 +917,7 @@ SELECT * WHERE {\
routeLayer.addTo(map);
if (options.busRoutes && options.busRouteControl) {
- var routeControl = new L.Control.Route(routeLayer, "sidebar", {
+ var routeControl = new L.Control.RouteSidebar(routeLayer, "sidebar", {
routeMasterSort: function(a, b) {
var refs = {
"U1": 1,
@@ -917,7 +929,7 @@ SELECT * WHERE {\
return refs[a] - refs[b];
},
- position: "right"
+ position: "left"
});
routeControl.addTo(map);
routeControl.show();