mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-06 03:11:22 +00:00
Adds geolocation for #157
This commit is contained in:
@@ -657,6 +657,10 @@ button.Browse .label {
|
||||
margin: 4px;
|
||||
}
|
||||
|
||||
.geolocate-control {
|
||||
top:260px;
|
||||
}
|
||||
|
||||
/* Map
|
||||
------------------------------------------------------- */
|
||||
|
||||
|
||||
15
js/id/id.js
15
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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user