Skip to content

Commit

Permalink
Asks user for permission to use current location and changes the map …
Browse files Browse the repository at this point in the history
…view to that location
  • Loading branch information
shannonturner committed Jun 25, 2016
1 parent 7eae325 commit 0935a8a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions site.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

This comment has been minimized.

Copy link
@alulsh

alulsh Jun 25, 2016

Member

I think we should use a lower zoom level, like zoom levels 11-14 - it should instead give a broader view of the region at first, then they can zoom in and pinpoint their exact location.

Alternatively, we could add a button that says "show me my neighborhood" where the user clicks and it then zooms into zoom level 16!

});
}

function done() {
dcBikeLanes.setStyle({ color: 'green', weight: 2 });

Expand Down

0 comments on commit 0935a8a

Please sign in to comment.