OpenLayers.Control.OverviewMap or deeper

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

OpenLayers.Control.OverviewMap or deeper

geekdenz
Hi List,

We have encountered a potential bug in OpenLayers:

When using GeoExt Panels and expanding a right hand side panel, the overview map moves. When one then uses the OverviewMap control by clicking on it, it behaves strangely in that the map is always zoomed to the left (west) of where one clicked. I found out that it is a problem in the event system.

I fixed it by doing this:
I had to dig deep into the OpenLayers code to find the problem. Basically the event system attaches an offset object (x,y) to the HTML element (<div/>). It assumes though that the element does not move and only changes this object when it changes. The overview map div, however, moves to the left when the right hand side panel is opened. I did suspect early on that this is the case but had to do some research as to where this happens and how to find a fix for it. The fix I applied was to delete the offset object whenever the rhs panel is expanded or collapsed. This seems to be a fundamental flaw in OpenLayers that map elements are assumed to not move on the page, because they definitely can when doing dynamic things with JavaScript.

From Events.js:
    getMousePosition: function (evt) {
        // ...
        if (!this.element.offsets) {
            this.element.offsets = OpenLayers.Util.pagePosition(this.element);
        }

Now, I couldn't think of a good fix for this yet, because we don't want to recalculate the position every time for every element. I guess that is why the condition is there:
if (!this.element.offsets) {
  //...
}
but I couldn't yet think of how to reset this or under which condition, at least not in a generic way. Is there a move event for html elements which could be listened for or something along those lines?

Thanks for reading.

Regards,
Tim

Tim-Hinnerk Heuer

Twitter: @geekdenz


_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev