[OpenLayers-Dev] Should ArcGISCache getURL "this.getResolution()"
be "this.map.getResolution()" instead?
dmiddlecamp at azavea.com
Fri Mar 2 17:52:33 EST 2012
I'll try to give this a whack, but someone else please jump in if
I'm saying anything foolish.
Assuming your overlay and baselayers use the same resolution / scale,
that fix sounds like it would work. I haven't tried to selectively
enable/disable layers based on zoom levels, so maybe someone more
experienced can chime in. I would have suggested min/maxZoomLevel,
but I suspect that won't give you the fine grained control you want.
The initial use case for this layer was to act as a baselayer. In
that scenario, a call to layer.getResolution is effectively equivalent
since the Map.js code has:
map.getResolution -> this.baseLayer.getResolution()
I was in the same boat, where I didn't want to necessarily assume that
someone's layer wasn't necessarily at the same scale/resolution, but
that the zoom levels would line up. Maybe someone more experienced
can chime in? Can you selectively enable/disable a layer by
manipulating its set of resolutions without globally changing
min/maxZoomLevel? I only looked for a few minutes, but I wasn't able
to find documentation / an example of that behavior.
If I were going to implement it, my first guess would be to configure
the layer to match your server, and just enable / change the
visibility of your overlay based on the zoom level, but maybe there is
a better way (is that clunky)? Apologies again, I haven't looked at
this in a while.
It sounds like you're trying to restrict which zoom levels are
available. It's definitely possible I'm not understanding the use
case exactly, so my apologies if this doesn't apply. Instead of
reconfiguring your layer, or causing your client layer configuration
to not match your server configuration, would it be possible to
instead use the min/max zoom level controls?
On Fri, Mar 2, 2012 at 3:11 PM, <joanne.mcgraw at sympatico.ca> wrote:
> My forum post doesn't seem be getting accepted to the mailing list (even
> though I'm a member as far as I know -
> so I'll just send it around directly instead...
> I'm hoping someone more knowledgeable in OpenLayers code can review this
> post and tell me if I am correct in my proposed fix and whether what I have
> observed is actually a bug or just the result of a misunderstanding on my
> I have an OpenLayers.Map with 3 resolutions available (e.g., resolutions =
> [1000,100, 10]). I have an ArcGISCache layer in the map that I only want
> available for display at the 100 and 10 resolutions (that is, it will show
> greyed out in the LayerSwitcher at 1000 and not be displayed in the map).
> When the user zooms in to the 100 resolution on the map (resolution 100 is
> in index 1 of the baselayer's resolution array), the current
> OpenLayers.Layer.ArcGISCache class' getURL method's first line of code ends
> up with the value of 10 (rather than 100) in the "res" variable because that
> is the item at index 1 in its own list of resolutions. Consequently, the
> method's algorithm generates invalid paths to the tiles in the cache.
> Originally, I started looked into the OpenLayers.Layer class' getResolution
> method. It seems to assume the map (or more specifically, the map's
> baselayer) and the layer in question at any given time will always have the
> same number of resolutions. That didn't seem like a safe assumption to me
> but I looked back through the history of the code and see that that method
> has been that way for years. So, I went looking around throughout OpenLayers
> and find that the OpenLayers.Layer's getResolution method is only used a
> handful of times (Grid and KaMap's getTileBounds and Image's resetBackBuffer
> and startTransition). This leads me to believe that the OpenLayers.Layer's
> getResolution method is more specific in its usage than I expect.
> Given that thought, I'm now thinking instead that the problem is just with
> the OpenLayers.Layer.ArcGISCache getURL method. Changing the use of the
> Layer's getResolution method might have farther reaching impacts than I
> could guess at. And, most other places in OpenLayers where a getResolution
> call is made, they are made to the map...as I am proposing doing.
> So, I have fixed my problem by changing the first line in the
> OpenLayers.Layer.ArcGISCache class method getURL to (the commented section
> at the end is the existing line of code):
> var res = this.map.getResolution(); // var res = this.getResolution();
> Could someone give me an idea if this is an acceptable approach? And, if so,
> would you consider it a bug that I should log?
> Oh, I am using ArcGIS Server 10.0 and OpenLayers 2.11.
> Dev mailing list
> Dev at lists.osgeo.org
David Middlecamp, Software Developer
Azavea | 340 N 12th St, Ste 402, Philadelphia, PA
dmiddlecamp at azavea.com | T 215.701.7688 | F 215.925.2663
Web azavea.com | Blog azavea.com/blogs | @dmiddlecamp
More information about the Dev