[OpenLayers-Users] Popup.setSize() - any reason why it should break in 2.2?

Erik Uzureau euzuro at gmail.com
Wed Dec 20 14:35:16 EST 2006


Hi Nick,

My immediate guess is that the problem here is that you are calling
setSize() before you
actually add the popup to the map.
When you call setSize() on an anchored bubble popup, it has to redo
its Rico corners, and
doing this involves calling the quadrant determination code. The
problem is that the popup
is not yet added to the map so it can't tell which quadrant it's in.

This is obviously a shortcoming in the popup engineering... though I'm
surprised that you weren't seeing this same error with 2.1

Try putting the setSize() after the add-to-map call and see if that fixes it?

Hope that helps. Let us know.
Erik


On 12/19/06, Nick Whitelegg <nick at hogweed.org> wrote:
>
> I've just converted my custom "GeoRSS2" layer (a layer which can handle
> retrieval of GeoRSS features within a bounding box) from OpenLayers 2.1 to
> 2.2. However one line breaks - I can no longer set the size of a popup within
> the markerClick function - I get the error "quadrant has no properties".
>
> My markerClick function is modified from the original GeoRSS.js function to
> handle deleting the marker if a user is in a certain mode, and is as below.
> Full code (if needed) is at http://www.free-map.org.uk/test/GeoRSS2.js.
>
> Is this an API change?
>
> Thanks,
> Nick
>
> markerClick: function(evt) {
>         if(this.layer.deleteTestFunction && this.layer.deleteFunction &&
>                 this.layer.deleteTestFunction()) {
>             this.layer.deleteFunction(this.id);
>             this.layer.removeMarker(this.marker);
>             this.destroy();
>         } else {
>             sameMarkerClicked = (this == this.layer.selectedFeature);
>             this.layer.selectedFeature = (!sameMarkerClicked) ? this : null;
>             for(var i=0; i < this.layer.map.popups.length; i++) {
>                 this.layer.map.removePopup(this.layer.map.popups[i]);
>             }
>             if (!sameMarkerClicked) {
>                 var popup = this.createPopup();
>                 // This breaks in 2.2
>                 //popup.setSize(this.layer.popupSize);
>                 popup.setBackgroundColor(this.layer.popupColour);
>                 OpenLayers.Event.observe(popup.div, "click",
>                 function() {
>                 for(var i=0; i < this.layer.map.popups.length; i++) {
>                     this.layer.map.removePopup(this.layer.map.popups[i]);
>                   }
>                 }.bindAsEventListener(this));
>                 this.layer.map.addPopup(popup);
>             }
>             OpenLayers.Event.stop(evt);
>         }
>     },
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>



More information about the Users mailing list