From: Tom Hughes Date: Wed, 16 Apr 2008 08:49:55 +0000 (+0000) Subject: Use OL 2.6 auto sizing for popups instead of doing it ourselves. X-Git-Tag: live~7802 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/25885677e277cc5def58fdd31e83fb474a9565a3?ds=sidebyside Use OL 2.6 auto sizing for popups instead of doing it ourselves. --- diff --git a/public/javascripts/map.js b/public/javascripts/map.js index 4a23d8590..9a834593d 100644 --- a/public/javascripts/map.js +++ b/public/javascripts/map.js @@ -74,11 +74,10 @@ function addMarkerToMap(position, icon, description) { function openMapPopup(marker, description) { closeMapPopup(); - popup = new OpenLayers.Popup.AnchoredBubble("popup", marker.lonlat, - sizeMapPopup(description), - "

" + description + "

", - marker.icon, true); + popup = new OpenLayers.Popup.AnchoredBubble("popup", marker.lonlat, null, + description, marker.icon, true); popup.setBackgroundColor("#E3FFC5"); + popup.autoSize = true; map.addPopup(popup); return popup; @@ -91,27 +90,6 @@ function closeMapPopup() { } } -function sizeMapPopup(text) { - var box = document.createElement("div"); - - box.innerHTML = text; - box.style.visibility = "hidden"; - box.style.position = "absolute"; - box.style.top = "0px"; - box.style.left = "0px"; - box.style.width = "200px"; - box.style.height = "auto"; - - document.body.appendChild(box); - - var width = box.offsetWidth; - var height = box.offsetHeight; - - document.body.removeChild(box); - - return new OpenLayers.Size(width + 30, height + 24); -} - function removeMarkerFromMap(marker){ markers.removeMarker(marker); }