[OpenLayers-Users] FramedCloud with Layer.Text?

Christopher Schmidt crschmidt at metacarta.com
Mon Apr 21 13:54:46 EDT 2008


On Mon, Apr 21, 2008 at 10:39:56AM -0400, Bobby H. Braswell wrote:
> 
> Hi-
> 
> Is there an example of using the framed cloud popups with a text layer  
> in 2.6? In general can we specify the popup type when constructing a  
> text layer?

Generally, the answer is 'no, and why are you still using a Layer.Text?
Use a Layer.GML with a format: OpenLayers.Format.Text and a
selectFeature control instead.' 

I understand that this is impractical for long running applications (we
maintain backwards API compatibility for a reason, after all). 

Anyway, the following hacks will let you get something that I like a lot
better for text layers:

        OpenLayers.Feature.prototype.popupClass = OpenLayers.Popup.FramedCloud;

        OpenLayers.Layer.Text.prototype.markerClick = function(evt) {
            var sameMarkerClicked = (this == this.layer.selectedFeature);
            if (this.popup) {
                this.popup.toggle(); 
            } else {
                this.layer.map.addPopup(this.createPopup(true));
            }
            this.layer.selectedFeature = (!sameMarkerClicked) ? this :
null;
            OpenLayers.Event.stop(evt);        
        }

Good Luck,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list