1 function initializeBrowse(map) {
4 var dataLayer = map.dataLayer;
21 dataLayer.isWayArea = function () {
25 dataLayer.on("click", function (e) {
29 map.on('layeradd', function (e) {
30 if (e.layer === dataLayer) {
31 map.on("moveend", updateData);
36 map.on('layerremove', function (e) {
37 if (e.layer === dataLayer) {
38 map.off("moveend", updateData);
39 $('#browse_status').empty();
43 function updateData() {
44 var bounds = map.getBounds();
45 if (!browseBounds || !browseBounds.contains(bounds)) {
50 function displayFeatureWarning(count, limit, callback) {
51 $('#browse_status').html(
52 $("<p class='warning'></p>")
53 .text(I18n.t("browse.start_rjs.feature_warning", { num_features: count, max_features: limit }))
55 $("<input type='submit'>")
56 .val(I18n.t('browse.start_rjs.load_data'))
63 var bounds = map.getBounds();
64 var url = "/api/" + OSM.API_VERSION + "/map?bbox=" + bounds.toBBoxString();
67 * Modern browsers are quite happy showing far more than 100 features in
68 * the data browser, so increase the limit to 2000 by default, but keep
69 * it restricted to 500 for IE8 and 100 for older IEs.
71 var maxFeatures = 2000;
74 if (navigator.appVersion < 8) {
76 } else if (navigator.appVersion < 9) {
81 if (dataLoader) dataLoader.abort();
85 success: function (xml) {
86 dataLayer.clearLayers();
89 var features = dataLayer.buildFeatures(xml);
91 function addFeatures() {
92 $('#browse_status').empty();
93 dataLayer.addData(features);
96 if (features.length < maxFeatures) {
99 displayFeatureWarning(features.length, maxFeatures, addFeatures);
103 browseBounds = bounds;
108 function onSelect(layer) {
109 // Unselect previously selected feature
111 selectedLayer.setStyle(selectedLayer.originalStyle);
114 // Redraw in selected style
115 layer.originalStyle = layer.options;
116 layer.setStyle({color: '#0000ff', weight: 8});
118 OSM.router.route('/' + layer.feature.type + '/' + layer.feature.id);
120 // Stash the currently drawn feature
121 selectedLayer = layer;