[OpenLayers-Dev] Saving and restoring map extent

Alexei Peters apeters at fargeo.com
Mon Aug 16 15:10:48 EDT 2010


Hey everyone,

For a project we're working on a user can save a map (extents, wms layers,
vectors, etc) and then come back during a later session and reload that map.

But we've noticed a small bug/feature in OL concerning the saving and
reloading of map extents.

If you run this in Firebug you'll see what I mean:

blah = map.getExtent();
map.zoomToExtent(blah);

Most of the time it seems when running the above code the map will zoom out
one step from what is currently displayed on the screen. So, for example, if
the map is at zoom level 7 when you call getExtent() then the map will be at
zoom level 6 after calling zoomToExtent().  From the end users perspective
this appears as a bug in our site.

Is this by design?  Is there a way to "fix" this?  I know that we could save
the zoom level and map center, but this would require a db schema change on
our end and for users with different screen sizes we do want the map to zoom
to the given extent.

Cheers,
Alexei
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20100816/aba60680/attachment.html


More information about the Dev mailing list