[OpenLayers-Dev] Re: OpenLayers 2.11 loading layer data regardless of maxResolution

Eric Lemoine eric.lemoine at camptocamp.com
Wed May 9 17:56:12 EDT 2012

On Wed, May 9, 2012 at 3:04 AM, Ruben Schoenefeld <rschoenefeld at utah.gov> wrote:
> I created two pages, one is using OpenLayers 2.10, the other one is using
> 2.11
> 2.10
> https://jdev.udot.utah.gov/apex/dev3/f?p=103:210
> 2.11
> https://jdev.udot.utah.gov/apex/dev3/f?p=103:211
> When either of those pages loads, they zoom out to show all of Utah. I
> turned on some default OpenLayers controls (navigation, etc) but not using
> the layer switcher, because instead of allowing multiple overlays, I am
> allowing only either the Routes layer or the Streets layer. In the version
> for 2.10, I am including a region defining OpenLayers.Layer.ArcGISCache but
> in 2.11 I left it out as it seems to be included in there already.
> When defining the routes and streets layers, I am using a subset of the
> resolutions array. For the routes layer, the allowable resolutions are:
> [19.1092578131615, 9.55462890525781, 4.77731445262891, 2.38865722657904,
> 1.19432861315723, 0.597164306578613, 0.298582153289307]
> For the street centerline layer, the resolutions are:
> [2.38865722657904, 1.19432861315723, 0.597164306578613, 0.298582153289307]
> In 2.10, everything works fine, I can zoom in and out, switch back and forth
> between the two layers (using the two items at the top of the page) and once
> the selected layer comes into range, the data is displayed as expected.
> In 2.11 however, if I am zoomed outside of the range of the resolutions of
> either routes or centerline and I switch from the routes layer (visibility:
> true when loaded) to the centerline layer, OpenLayers loads first the routes
> and then the centerlines data, which, when you are zoomed out far enough to
> show the whole state will very likely crash your browser, so zoom in a
> little bit first.
> In the console (use Firebug etc to display), I am showing the map resolution
> and whether or not route and centerline layers are in range (using
> layer.calculateInRange()). Once you click the links to change layers, that's
> displayed in the console as well.
> Some other thing I noticed: In 2.10, when zoomed out all the way, I can
> double click on a point to zoom in by two steps, or draw a zoom box while
> holding the shift key. In 2.11, when I do that, The map does not go where I
> drew the zoom box but slides north (at least while trying it out now). I
> suspect I am just doing something wrong when creating the layers, but maybe
> somebody has an idea about that too. That's actually not something I noticed
> earlier, so it might just happen in this minimal example.

Thanks for the examples and detailed explanations.

I think the problem was introduced by [*}. With this commit the BBOX
strategy listens to "visibilitychanged" on the layer and
unconditionally updates the layer when this event is triggered. So if
the layer is invisible and out-of-range, when it's made visible the
strategy updates the layer even though it's out of range. It would be
good to have someone write a patch for that.

[*] <https://github.com/openlayers/openlayers/commit/afb80bfe4899e9ffd3962bd0adcc82019647717d>

Eric Lemoine

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

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com

More information about the Dev mailing list