1 OSM.initializeBrowse = function (map) {
3 var dataLayer = map.dataLayer;
20 dataLayer.isWayArea = function () {
24 dataLayer.on("click", function (e) {
28 map.on("layeradd", function (e) {
29 if (e.layer === dataLayer) {
30 map.on("moveend", updateData);
35 map.on("layerremove", function (e) {
36 if (e.layer === dataLayer) {
37 map.off("moveend", updateData);
38 $("#browse_status").empty();
42 function updateData() {
43 var bounds = map.getBounds();
44 if (!browseBounds || !browseBounds.contains(bounds)) {
49 function displayFeatureWarning(count, limit, add, cancel) {
50 $("#browse_status").html(
53 $("<button type='button' class='btn-close float-end mt-1'>")
56 .text(I18n.t("browse.start_rjs.load_data"))
60 $("<p class='alert alert-warning clearfix'></p>")
61 .text(I18n.t("browse.start_rjs.feature_warning", { num_features: count, max_features: limit })))
63 $("<input type='submit' class='btn btn-primary'>")
64 .val(I18n.t("browse.start_rjs.load_data"))
71 var bounds = map.getBounds();
72 var url = "/api/" + OSM.API_VERSION + "/map?bbox=" + bounds.toBBoxString();
75 * Modern browsers are quite happy showing far more than 100 features in
76 * the data browser, so increase the limit to 2000 by default, but keep
77 * it restricted to 500 for IE8 and 100 for older IEs.
79 var maxFeatures = 2000;
82 if (navigator.appVersion < 8) {
84 } else if (navigator.appVersion < 9) {
89 if (dataLoader) dataLoader.abort();
93 success: function (xml) {
94 dataLayer.clearLayers();
96 var features = dataLayer.buildFeatures(xml);
98 function addFeatures() {
99 $("#browse_status").empty();
100 dataLayer.addData(features);
101 browseBounds = bounds;
104 function cancelAddFeatures() {
105 $("#browse_status").empty();
108 if (features.length < maxFeatures) {
111 displayFeatureWarning(features.length, maxFeatures, addFeatures, cancelAddFeatures);
114 if (map._objectLayer) {
115 map._objectLayer.bringToFront();
123 function onSelect(layer) {
124 OSM.router.route("/" + layer.feature.type + "/" + layer.feature.id);