[OpenLayers-Users] Ancored Popup Autosize troubles

smithfield willsmithfield at gmail.com
Wed Jan 28 13:31:51 EST 2009


Brilliant,  The autosize now works but the popups are being placed all over
the map.  What could be causing this behavior?

For the record here is what I have done...

	//creates popup win / removes old popup if it exists
        	function createPopup(feature){
            if (popup != null) {
                map.removePopup(popup);
                popup.destroy();
                popup = null;
            }
            feature.lonlat = feature.geometry.getBounds().getCenterLonLat();

            if (popup == null) {

                 popup = new OpenLayers.Popup.Anchored ("popup",
feature.lonlat, new OpenLayers.Size(null), null, null, null, function () { 
                               map.removePopup( popup ); popup.destroy();
popup = null;});


                var content = "<div>"+ feature.attributes.CNTRY_NAME +
"</div><br>" +
                    "<div><table>" +
                    "<tr><th align='right'>Overall Rank:</th><td> " +
feature.attributes.Act_T + "</td></tr>" +
                    "<tr><th align='right'>Government Rank:</th><td> " +
feature.attributes.Act_G + "</td></tr>" +
                    "<tr><th align='right'>Industry Rank:</th><td>" +
feature.attributes.Act_I + "</td></tr>" +
                    "<tr><th align='right'>Community Rank:</th><td> " +
feature.attributes.Act_C + " </td></tr>" +
                    "</table></div>";

                 popup.setContentHTML(content);

                popup.setBackgroundColor("white");
                popup.setOpacity(1);
                popup.events.register('mousemove', popup, function (e)
{try{e.stopPropagation();}catch(e){}});
                map.addPopup(popup);	
popup.autoSize = true;
          	} else {
                map.removePopup(popup);
                popup.destroy();
                popup = null;
           	}

        	}

        	// remove popup - set to null
       	function unSelect(){
            if (popup != null) {
                map.removePopup(popup);
                popup.destroy();
                popup = null;
            }
        	}


    </script>
  </head>
  <body onload="init()">
    <center>
      <div id="map"></div>
    </center>
  </body>
</html>

-- 
View this message in context: http://n2.nabble.com/Ancored-Popup-Autosize-troubles-tp2221855p2233940.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list