]> git.openstreetmap.org Git - rails.git/commitdiff
Use OL 2.6 auto sizing for popups instead of doing it ourselves.
authorTom Hughes <tom@compton.nu>
Wed, 16 Apr 2008 08:49:55 +0000 (08:49 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 16 Apr 2008 08:49:55 +0000 (08:49 +0000)
public/javascripts/map.js

index 4a23d8590ea290f528ee80b168e3b5b053587d71..9a834593d996cb1377f0e72910c4faaced68d276 100644 (file)
@@ -74,11 +74,10 @@ function addMarkerToMap(position, icon, description) {
 function openMapPopup(marker, description) {
    closeMapPopup();
 
-   popup = new OpenLayers.Popup.AnchoredBubble("popup", marker.lonlat,
-                                               sizeMapPopup(description),
-                                               "<p style='padding-right: 28px'>" + description + "</p>",
-                                               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);
 }