[OpenLayers-Users] "position: fixed" map

Ciaran Power ciaran.power at gmail.com
Fri Jul 30 09:39:36 EDT 2010


Hi all,

I want a user to be able to bring a map up by clicking a button, and I 
want the map in a fixed position ("position: fixed" in css). This works 
fine on pages that can't be scrolled. If I have a page containing a lot 
of text, and the user scrolls down towards the bottom, then the 
mouse-wheel zoom feature doesn't zoom to the correct position.

As an example, if I take the osm.html example 
(http://openlayers.org/dev/examples/osm.html), add a couple of pages of 
lorem ipsum after the map, and put:

#map {
    position: fixed;

    top: 100px;
    left: 100px;
}

in style.css. Then scroll down to the bottom of the page, and try to 
zoom using the middle mouse button, the place I end up zooming to has 
very little to do with where the mouse is positioned. On the other hand, 
if I scroll to the top of the page, then everything works as expected.

Has anyone met this before, or know if I'm doing something wrong etc.? 
OpenLayers 2.9.1 on Iceweasel 3.0.6.

Thanks,
Ciaran




More information about the Users mailing list