X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/7ad58d1411289ad241a49abb87e414ff13b60173..0ba1839e78e694ab4ac1ca9fc650df1eec101b7c:/app/assets/javascripts/map.js.erb?ds=inline diff --git a/app/assets/javascripts/map.js.erb b/app/assets/javascripts/map.js.erb index d976b9f8c..c06c9c8ea 100644 --- a/app/assets/javascripts/map.js.erb +++ b/app/assets/javascripts/map.js.erb @@ -71,6 +71,16 @@ function createMap(divName, options) { }); map.addLayer(markers); + map.dataLayer = new OpenLayers.Layer(I18n.t('browse.start_rjs.data_layer_name'), { + visibility: false, + displayInLayerSwitcher: false + }); + map.addLayer(map.dataLayer); + + $("#" + divName).on("resized", function () { + map.updateSize(); + }); + return map; } @@ -96,13 +106,13 @@ function addMarkerToMap(position, icon, description) { return marker; } -function addObjectToMap(url, zoom, callback) { +function addObjectToMap(object, zoom, callback) { var layer = new OpenLayers.Layer.Vector("Objects", { strategies: [ new OpenLayers.Strategy.Fixed() ], protocol: new OpenLayers.Protocol.HTTP({ - url: url, + url: OSM.apiUrl(object), format: new OpenLayers.Format.OSM() }), style: { @@ -186,7 +196,6 @@ function openMapPopup(marker, description) { function closeMapPopup() { if (popup) { map.removePopup(popup); - delete popup; } } @@ -194,10 +203,6 @@ function removeMarkerFromMap(marker){ markers.removeMarker(marker); } -function removeBoxFromMap(box){ - vectors.removeFeature(box); -} - function proj(x) { return x.clone().transform(epsg4326, map.getProjectionObject()); } @@ -214,7 +219,7 @@ function setMapCenter(center, zoom) { } function getEventPosition(event) { - return map.getLonLatFromViewPortPx(event.xy).clone().transform(map.getProjectionObject(), epsg4326); + return unproj(map.getLonLatFromViewPortPx(event.xy)); } function getMapLayers() {