//= require templates/browse/feature_list
//= require templates/browse/feature_history
-$(document).ready(function () {
+function initializeBrowse(map, params) {
var browseBounds;
var layersById;
var selectedLayer;
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"
}
});
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) {
}
});
+ 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,
openSidebar();
+ if (browseObjectList) loadObjectList();
+
map.on("moveend", updateData);
updateData();
getData();
}
- function toggleAreas() {
+ function toggleAreas(e) {
+ e.preventDefault();
+
if (areasHidden) {
$("#browse_hide_areas_box").html(I18n.t('browse.start_rjs.hide_areas'));
areasHidden = false;
$("#browse_content").append(div);
}
+ var dataLoader;
+
function getData() {
var bounds = locationFilter.isEnabled() ? locationFilter.getBounds() : map.getBounds();
var size = bounds.getSize();
}
@*/
- $.ajax({
+ if (dataLoader) dataLoader.abort();
+
+ dataLoader = $.ajax({
url: url,
success: function (xml) {
clearStatus();
} else {
displayFeatureWarning(features.length, maxFeatures, addFeatures);
}
+
+ dataLoader = null;
}
});
}
$("#browse_status").html("");
$("#browse_status").hide();
}
-});
+}