Commit ce740b4b authored by Kevin Abel's avatar Kevin Abel
Browse files

Update bus marker icon to use directional icon, centered

Also updates the bus loop to match production timeout and json endpoint.
The expectation is that there is an external process that continually
processes the busproxy script that updates the bus.json file.
parent 3c534acb
......@@ -89,6 +89,17 @@
}
},
angleToCardinal = function(angle) {
var cardinals = ['n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw'], i;
i = Math.round(angle / (360 / cardinals.length)) % cardinals.length;
if (i < 0) {
i += cardinals.length;
}
return cardinals[i];
},
initialize = function(markerTypes) {
var
mapOptions = {
......@@ -301,7 +312,7 @@
busLoop = function() {
busTimeout = true;
$.ajax({
url: UNL_TOUR_URL + 'busproxy.php',
url: UNL_TOUR_URL + 'bus.json',
dataType: 'json',
success: function(data) {
$.each(data.VehicleArray, function(key, value) {
......@@ -319,14 +330,20 @@
return;
}
var icon = {
url: UNL_TOUR_URL + 'images/markers/google/bus-' + angleToCardinal(value.vehicle.CVLocation.angle) + '.png',
anchor: new google.maps.Point(16, 16)
};
if (markers['buses'][value.vehicle.id]) {
markers['buses'][value.vehicle.id].setPosition(new google.maps.LatLng(value.vehicle.CVLocation.latitude/100000, value.vehicle.CVLocation.longitude/100000));
markers['buses'][value.vehicle.id].setIcon(icon);
} else {
markers['buses'][value.vehicle.id] = new google.maps.Marker({
position : new google.maps.LatLng(value.vehicle.CVLocation.latitude/100000, value.vehicle.CVLocation.longitude/100000),
map : UNLTourMap.map,
title : 'Route ' + value.vehicle.routeID,
icon : UNL_TOUR_URL + 'images/markers/google/busstop.png',
icon : icon,
clickable: false,
});
}
......@@ -334,7 +351,7 @@
},
complete: function() {
if (busTimeout) {
busTimeout = setTimeout(busLoop, 500);
busTimeout = setTimeout(busLoop, 1500);
}
}
});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment