[OpenLayers-Dev] Saving and restoring map extent

Bruno Binet bruno.binet at camptocamp.com
Tue Aug 17 05:51:27 EDT 2010


This might be a rounding issue. I encountered a similar issue related
to WMC a while ago, and the fix was to keep a better precision when
parsing floats. ( http://trac.openlayers.org/ticket/2242 )
You can try to set the default precision to 18 for example, instead of
14, or set it to 0 so that the original non-truncating behavior of
OpenLayers <2.8 is preserved.

OpenLayers.Util.DEFAULT_PRECISION = 18;

Cheers,
Bruno

On 16 August 2010 21:10, Alexei Peters <apeters at fargeo.com> 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);
>
> 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
>
>



-- 
Bruno Binet

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Mail : bruno.binet at camptocamp.com
http://www.camptocamp.com



More information about the Dev mailing list