X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/b1308a87be1aaa0c6e5fd27e0635ef22b76e8081..370f4bf562845a864e425f25bb8279afcb7016c3:/app/assets/javascripts/map.js.erb diff --git a/app/assets/javascripts/map.js.erb b/app/assets/javascripts/map.js.erb index 990093570..8591e260a 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) { @@ -184,13 +189,13 @@ function getMapBaseLayer() { } function getMapLayers() { + var layerConfig = ""; for (var i = 0; i < layers.length; i++) { if (map.hasLayer(layers[i].layer)) { - return layers[i].layerCode; + layerConfig += layers[i].layerCode; } } - - return ""; + return layerConfig; } function setMapLayers(layerConfig) {