Skip to content

Instantly share code, notes, and snippets.

@ZacSweers
Forked from blech/caltrain.geojson
Created November 6, 2015 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZacSweers/99d61295437042746dd9 to your computer and use it in GitHub Desktop.
Save ZacSweers/99d61295437042746dd9 to your computer and use it in GitHub Desktop.
Caltrain Ridership
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Caltrain Ridership | blech.github.io</title>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<script src='//api.tiles.mapbox.com/mapbox.js/v1.6.1/mapbox.js'></script>
<script src='//api.tiles.mapbox.com/mapbox.js/plugins/leaflet-hash/v0.2.1/leaflet-hash.js'></script>
<link href='//api.tiles.mapbox.com/mapbox.js/v1.6.1/mapbox.css' rel='stylesheet' />
<link href="/geojson/{{ date }}" rel="geojson" type="application/json">
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<div id='map'></div>
<script>
var map = L.mapbox.map('map', 'paulmison.gofl3m15')
.setView([37.5326, -122.1305], 11);
var hash = new L.Hash(map);
var draw_geojson = function(data) {
var markerLayer = L.mapbox.markerLayer()
markerLayer.setGeoJSON(data).addTo(map);
map.fitBounds(markerLayer.getBounds());
};
var draw_data = function(data) {
var featureGroup = L.featureGroup().addTo(map);
var options = {
color: '#000', // Stroke color
opacity: 1, // Stroke opacity
weight: 1, // Stroke weight
fillColor: '#933', // Fill color
fillOpacity: 0.6 // Fill opacity
};
for (var i = 0; i < data['features'].length; i++) {
feature = data['features'][i]
console.log(feature['geometry']['coordinates'])
console.log(feature['properties'])
var coords = [feature['geometry']['coordinates'][1], feature['geometry']['coordinates'][0]]
var radius = Math.sqrt(200*feature['properties']['2013'])
var circle = L.circle(coords, radius, options).addTo(featureGroup);
}
}
$.getJSON('/blech/raw/8838444/caltrain.geojson', draw_geojson);
$.getJSON('/blech/raw/8838444/dotspotting-sheet-2969.json', draw_data);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment