[OpenLayers-Dev] Saving and restoring map extent

Tim Schaub tschaub at opengeo.org
Tue Aug 17 11:48:23 EDT 2010


On 8/16/10 1:10 PM, Alexei Peters wrote:
> 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);

     map.zoomToExtent(blah, true);

http://dev.openlayers.org/apidocs/files/OpenLayers/Map-js.html#OpenLayers.Map.zoomToExtent

> 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
>
>
>
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev


-- 
Tim Schaub
OpenGeo - http://opengeo.org
Expert service straight from the developers.



More information about the Dev mailing list