diff --git a/css/app.css b/css/app.css index 9955a37ed..c960d5ddb 100644 --- a/css/app.css +++ b/css/app.css @@ -657,6 +657,10 @@ button.Browse .label { margin: 4px; } +.geolocate-control { + top:260px; +} + /* Map ------------------------------------------------------- */ diff --git a/js/id/id.js b/js/id/id.js index 48c7f307d..3aa6802f3 100644 --- a/js/id/id.js +++ b/js/id/id.js @@ -190,6 +190,21 @@ window.iD = function(container) { return d[0] + ' icon'; }); + function geolocateSuccess(position) { + map.center([position.coords.longitude, position.coords.latitude]); + } + function geolocateError() { } + if (navigator.geolocation) { + container.append('div') + .attr('class', 'geolocate-control map-control') + .append('button') + .attr('class', 'narrow') + .text('G') + .on('click', function() { + navigator.geolocation.getCurrentPosition(geolocateSuccess, geolocateError); + }); + } + var gc = container.append('div').attr('class', 'geocode-control map-control') .call(iD.geocoder().map(map));