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());
27 zoom: params.zoom || 17,
31 $('.start-mapping').attr('href', '/edit?' + $.param(params));
33 } else if (navigator.geolocation) {
34 $('.edit-geolocated').show();
36 function geoSuccess(position) {
37 window.location = '/edit?zoom=17&lat=' + position.coords.latitude + '&lon=' + position.coords.longitude;
42 .removeClass('loading')
46 $('.start-mapping').on('click', function(e) {
52 // handle firefox's weird implementation
53 // https://bugzilla.mozilla.org/show_bug.cgi?id=675533
54 window.setTimeout(geoError, 4000);
56 navigator.geolocation.getCurrentPosition(geoSuccess, geoError);