Created
February 5, 2014 22:00
-
-
Save jackp/8834094 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get list of all bus-stop routes from JSON | |
$.getJSON('cached_busroutes.json', function(routes){ | |
// Get bus stops for Bedford Lane | |
var allBusStops = routes["bedford"]["lane"]; | |
// NOTE: Assuming underscore is available | |
_.each(allBusStops, function(busStop){ | |
// Declare the map, centering at desired location | |
var busStops = allBusStops[busStop]; | |
var map = new GMaps({ | |
div: '#map' + busno, | |
lat: busstops[0]["lat"], | |
lng: busstops[0]["lng"], | |
draggable: false, | |
disableDoubleClickZoom: true, | |
streetViewControl: false, | |
scrollwheel: false, | |
panControl: true, | |
scaleControl: true | |
}); | |
// Get bounds to center map | |
var bounds = new google.maps.LatLngBounds(); | |
// the base location for icon markers | |
var iconBase = "https://dl.dropboxusercontent.com/u/21803943/maps-icons/darkgrey/"; | |
// Run through bus stops | |
_.each(busStops, function(busStop, index){ | |
var j = index + 1; | |
// we want the markers to show the bus stop number | |
(function(count, iconUrl) { | |
// get the location, on success, add the marker | |
var latlng = new google.maps.LatLng(busstop["lat"], busstop["lng"]); | |
map.addMarker({ | |
lat: latlng.lat(), | |
lng: latlng.lng(), | |
icon: iconUrl, | |
title: busstop["add"], | |
infoWindow: { | |
content: busstop["info"] | |
} | |
}); | |
$(".stops" + busstop["bus_no"]).append("<p>" + j + ". " + busstop["add"] + " " + "<strong>" + busstop["variant"] + "</strong></p>"); | |
// center the maps | |
bounds.extend(latlng); | |
map.map.fitBounds(bounds); | |
})(i, iconBase + (i + 1) + ".png"); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment