X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/5e9ab5bc5edb63b7ab7719fa989a18f52e3637a2..26855add3861ad496efdcae8598ffdf7d1116074:/app/assets/javascripts/index/browse.js diff --git a/app/assets/javascripts/index/browse.js b/app/assets/javascripts/index/browse.js index e04a864f4..d8de69974 100644 --- a/app/assets/javascripts/index/browse.js +++ b/app/assets/javascripts/index/browse.js @@ -2,7 +2,7 @@ //= require templates/browse/feature_list //= require templates/browse/feature_history -function initializeBrowse(map) { +function initializeBrowse(map, params) { var browseBounds; var layersById; var selectedLayer; @@ -49,6 +49,12 @@ function initializeBrowse(map) { } }); + if (OSM.STATUS != 'api_offline' && OSM.STATUS != 'database_offline') { + if (params.layers.indexOf(dataLayer.options.code) >= 0) { + map.addLayer(dataLayer); + } + } + function startBrowse(sidebarHtml) { locationFilter = new L.LocationFilter({ enableButton: false, @@ -62,6 +68,8 @@ function initializeBrowse(map) { openSidebar(); + if (browseObjectList) loadObjectList(); + map.on("moveend", updateData); updateData(); @@ -105,7 +113,9 @@ function initializeBrowse(map) { getData(); } - function toggleAreas() { + function toggleAreas(e) { + e.preventDefault(); + if (areasHidden) { $("#browse_hide_areas_box").html(I18n.t('browse.start_rjs.hide_areas')); areasHidden = false; @@ -136,6 +146,8 @@ function initializeBrowse(map) { $("#browse_content").append(div); } + var dataLoader; + function getData() { var bounds = locationFilter.isEnabled() ? locationFilter.getBounds() : map.getBounds(); var size = bounds.getSize(); @@ -164,7 +176,9 @@ function initializeBrowse(map) { } @*/ - $.ajax({ + if (dataLoader) dataLoader.abort(); + + dataLoader = $.ajax({ url: url, success: function (xml) { clearStatus(); @@ -203,6 +217,8 @@ function initializeBrowse(map) { } else { displayFeatureWarning(features.length, maxFeatures, addFeatures); } + + dataLoader = null; } }); }