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(
54 .text(I18n.t("browse.start_rjs.load_data"))
55 .prepend($("<span class='icon close'></span>").click(cancel)))
59 $("<p class='alert alert-warning clearfix'></p>")
60 .text(I18n.t("browse.start_rjs.feature_warning", { num_features: count, max_features: limit })))
62 $("<input type='submit' class='btn btn-primary'>")
63 .val(I18n.t("browse.start_rjs.load_data"))
70 var bounds = map.getBounds();
71 var url = "/api/" + OSM.API_VERSION + "/map?bbox=" + bounds.toBBoxString();
74 * Modern browsers are quite happy showing far more than 100 features in
75 * the data browser, so increase the limit to 2000 by default, but keep
76 * it restricted to 500 for IE8 and 100 for older IEs.
78 var maxFeatures = 2000;
81 if (navigator.appVersion < 8) {
83 } else if (navigator.appVersion < 9) {
88 if (dataLoader) dataLoader.abort();
92 success: function (xml) {
93 dataLayer.clearLayers();
95 var features = dataLayer.buildFeatures(xml);
97 function addFeatures() {
98 $("#browse_status").empty();
99 dataLayer.addData(features);
100 browseBounds = bounds;
103 function cancelAddFeatures() {
104 $("#browse_status").empty();
107 if (features.length < maxFeatures) {
110 displayFeatureWarning(features.length, maxFeatures, addFeatures, cancelAddFeatures);
118 function onSelect(layer) {
119 OSM.router.route("/" + layer.feature.type + "/" + layer.feature.id);