X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/9d33721630e02ab9bed1d7853be4fcb5960d7b4f..aa20398cea1c212f27d9004170bdc0aee4d8f854:/app/assets/javascripts/index/browse.js diff --git a/app/assets/javascripts/index/browse.js b/app/assets/javascripts/index/browse.js index e98e56b27..f00d3999f 100644 --- a/app/assets/javascripts/index/browse.js +++ b/app/assets/javascripts/index/browse.js @@ -10,20 +10,20 @@ function initializeBrowse(map) { var areasHidden = false; var locationFilter; - var dataLayer = new L.OSM.DataLayer(null, { - styles: { - way: { - weight: 3, - color: "#000000", - opacity: 0.4 - }, - area: { - weight: 3, - color: "#ff0000" - }, - node: { - color: "#00ff00" - } + var dataLayer = map.dataLayer; + + dataLayer.setStyle({ + way: { + weight: 3, + color: "#000000", + opacity: 0.4 + }, + area: { + weight: 3, + color: "#ff0000" + }, + node: { + color: "#00ff00" } }); @@ -35,10 +35,6 @@ function initializeBrowse(map) { onSelect(e.layer); }); - if (OSM.STATUS != 'api_offline' && OSM.STATUS != 'database_offline') { -// map.layersControl.addOverlay(dataLayer, I18n.t("browse.start_rjs.data_layer_name")); - } - map.on('layeradd', function (e) { if (e.layer === dataLayer) { $.ajax({ url: "/browse/start", success: function (sidebarHtml) { @@ -61,10 +57,9 @@ function initializeBrowse(map) { locationFilter.on("change", getData); - $("#sidebar_title").html(I18n.t('browse.start_rjs.data_frame_title')); $("#sidebar_content").html(sidebarHtml); - openSidebar(); + if (browseObjectList) loadObjectList(); map.on("moveend", updateData); updateData(); @@ -109,7 +104,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; @@ -140,6 +137,8 @@ function initializeBrowse(map) { $("#browse_content").append(div); } + var dataLoader; + function getData() { var bounds = locationFilter.isEnabled() ? locationFilter.getBounds() : map.getBounds(); var size = bounds.getSize(); @@ -168,7 +167,9 @@ function initializeBrowse(map) { } @*/ - $.ajax({ + if (dataLoader) dataLoader.abort(); + + dataLoader = $.ajax({ url: url, success: function (xml) { clearStatus(); @@ -207,6 +208,8 @@ function initializeBrowse(map) { } else { displayFeatureWarning(features.length, maxFeatures, addFeatures); } + + dataLoader = null; } }); }