diff --git a/site.js b/site.js index 419a653..d5f278a 100644 --- a/site.js +++ b/site.js @@ -11,6 +11,13 @@ var dcBikeLanes = L.mapbox.featureLayer().addTo(map); dcBikeLanes.loadURL('./DC_bikelanes.geojson') .on('ready', done); +// Try to get user's current location and set the view +if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(function (position) { + map.setView([position.coords.latitude, position.coords.longitude], 16); + }); +} + function done() { dcBikeLanes.setStyle({ color: 'green', weight: 2 }); @@ -19,12 +26,17 @@ function done() { if (isNaN(radius)) radius = 500; var buffer = turf.buffer(dcBikeLanes.getGeoJSON(), radius/5280, 'miles'); - bufferLayer.setGeoJSON(buffer) - .setStyle({ - "fill": "#FF69B4", - "stroke": "#FF69B4", - "stroke-width": 2 - }); + + // Each buffer feature object needs to have the properties set individually + for (var i=0; i