Skip to content
Snippets Groups Projects
Commit 381a7d2d authored by Anton Sarukhanov's avatar Anton Sarukhanov
Browse files

js logic bugfix

parent c81f72b8
No related branches found
No related tags found
1 merge request!1Implemented Embed-code generator interface
...@@ -98,14 +98,15 @@ BusMap.Map = function(opts) { ...@@ -98,14 +98,15 @@ BusMap.Map = function(opts) {
$.getJSON(url, params) $.getJSON(url, params)
.done(function(data) { .done(function(data) {
// Store vehicle locations // Store vehicle locations
that.vehicles = data.locations; if (!that.vehicles) that.vehicles = [];
for (var v in data.locations) {
that.vehicles[v] = data.locations[v];
that.vehicles[v].predictions = [];
}
// Store predictions // Store predictions
for (var s in that.stops) { for (var s in that.stops) {
that.stops[s].predictions = {}; that.stops[s].predictions = {};
} }
for (var v in that.vehicles) {
that.vehicles[v].predictions = [];
}
for (var p in data.predictions) { for (var p in data.predictions) {
pr = data.predictions[p]; pr = data.predictions[p];
if (that.stops && pr.stop_id in that.stops) { if (that.stops && pr.stop_id in that.stops) {
...@@ -120,7 +121,6 @@ BusMap.Map = function(opts) { ...@@ -120,7 +121,6 @@ BusMap.Map = function(opts) {
that.vehicles[pr.vehicle].predictions.push(pr); that.vehicles[pr.vehicle].predictions.push(pr);
} }
} }
that.vehicles = data.locations;
updateVehiclesUI(that.vehicles); updateVehiclesUI(that.vehicles);
updateStopsUI(that.stops); updateStopsUI(that.stops);
}); });
...@@ -164,13 +164,13 @@ BusMap.Map = function(opts) { ...@@ -164,13 +164,13 @@ BusMap.Map = function(opts) {
direction: 'right', direction: 'right',
clickable: true, clickable: true,
}).bindPopup(text + footer, popupOpts).addTo(that.vehicleMarkersGroup); }).bindPopup(text + footer, popupOpts).addTo(that.vehicleMarkersGroup);
that.vehicleMarkers[v].label.on('click', function() {
this._source.openPopup();
});
} else { } else {
that.vehicleMarkers[v].setLatLng([vehicles[v].lat, vehicles[v].lon]) that.vehicleMarkers[v].setLatLng([vehicles[v].lat, vehicles[v].lon])
.setIconAngle(vehicles[v].heading); .setIconAngle(vehicles[v].heading);
} }
that.vehicleMarkers[v].label.on('click', function() {
this._source.openPopup();
});
that.vehicleMarkers[v].bm_updated = Date.now() that.vehicleMarkers[v].bm_updated = Date.now()
// Add predictions to the marker popup, if available // Add predictions to the marker popup, if available
......
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