1 $(document).ready(function() {
2 var params = OSM.params();
4 if (params.lat && params.lon) {
5 $('.edit-located').show();
8 url: "http://nominatim.openstreetmap.org/reverse",
14 success: function(xml) {
15 var result = $(xml).find('result');
17 $('.edit-located').hide();
18 $('.edit-geocoded').show();
19 $('.edit-geocoded-location').text(result.text());
24 $('.start-mapping').attr('href', '/edit?zoom=17&lat=' + params.lat + '&lon=' + params.lon);
26 } else if (navigator.geolocation) {
27 $('.edit-geolocated').show();
29 function geoSuccess(position) {
30 window.location = '/edit?zoom=17&lat=' + position.coords.latitude + '&lon=' + position.coords.longitude;
35 .removeClass('loading')
39 $('.start-mapping').on('click', function(e) {
45 // handle firefox's weird implementation
46 // https://bugzilla.mozilla.org/show_bug.cgi?id=675533
47 window.setTimeout(geoError, 4000);
49 navigator.geolocation.getCurrentPosition(geoSuccess, geoError);