X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/b1308a87be1aaa0c6e5fd27e0635ef22b76e8081..d1660a1c4fb71b61b7bd9181a2ec3822652bc29e:/app/assets/javascripts/map.js.erb diff --git a/app/assets/javascripts/map.js.erb b/app/assets/javascripts/map.js.erb index 990093570..48fd35d0e 100644 --- a/app/assets/javascripts/map.js.erb +++ b/app/assets/javascripts/map.js.erb @@ -50,6 +50,7 @@ L.Icon.Default.imagePath = <%= "#{asset_prefix}/images".to_json %>; var map; var objectLayer; +var objectLoader; var layers = [ { @@ -129,11 +130,15 @@ function getUserIcon(url) { } function addObjectToMap(object, zoom, callback) { + if (objectLoader) { + objectLoader.abort(); + } + if (objectLayer) { map.removeLayer(objectLayer); } - $.ajax({ + objectLoader = $.ajax({ url: OSM.apiUrl(object), dataType: "xml", success: function (xml) {