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(
52 $("<div class='d-flex'>").append(
53 $("<h2 class='flex-grow-1 text-break'>")
54 .text(I18n.t("browse.start_rjs.load_data")),
56 $("<button type='button' class='btn-close'>")
58 $("<p class='alert alert-warning'>")
59 .text(I18n.t("browse.start_rjs.feature_warning", { num_features: count, max_features: limit })),
60 $("<input type='submit' class='btn btn-primary'>")
61 .val(I18n.t("browse.start_rjs.load_data"))
68 var bounds = map.getBounds();
69 var url = "/api/" + OSM.API_VERSION + "/map?bbox=" + bounds.toBBoxString();
72 * Modern browsers are quite happy showing far more than 100 features in
73 * the data browser, so increase the limit to 2000 by default, but keep
74 * it restricted to 500 for IE8 and 100 for older IEs.
76 var maxFeatures = 2000;
79 if (navigator.appVersion < 8) {
81 } else if (navigator.appVersion < 9) {
86 if (dataLoader) dataLoader.abort();
90 success: function (xml) {
91 dataLayer.clearLayers();
93 var features = dataLayer.buildFeatures(xml);
95 function addFeatures() {
96 $("#browse_status").empty();
97 dataLayer.addData(features);
98 browseBounds = bounds;
101 function cancelAddFeatures() {
102 $("#browse_status").empty();
105 if (features.length < maxFeatures) {
108 displayFeatureWarning(features.length, maxFeatures, addFeatures, cancelAddFeatures);
111 if (map._objectLayer) {
112 map._objectLayer.bringToFront();
120 function onSelect(layer) {
121 OSM.router.route("/" + layer.feature.type + "/" + layer.feature.id);