[OpenLayers-Trac] [OpenLayers] #3633: Layer.ArcGISCache getURL
method should use this.map.getResolution()
OpenLayers
trac-20090302 at openlayers.org
Tue Mar 6 11:52:08 EST 2012
#3633: Layer.ArcGISCache getURL method should use this.map.getResolution()
------------------------------------+---------------------------------------
Reporter: myOpenLayersUName | Owner:
Type: bug | Status: new
Priority: minor | Milestone: 2.12 Release
Component: Layer.ArcGISCache | Version: 2.11
Keywords: resolutions visibility | State: Review
------------------------------------+---------------------------------------
To illustrate the problem I have encountered:
1. Use the OpenLayers example "ArcGIS Server Map Cache Example (Direct
Access) (arcgiscache_direct.html)" as released for OpenLayers 2.11.
2. Change the number of resolutions the overlaylayer will be visible at to
be fewer than those available for the entire map. There are multiple ways
this can be done, but the simplest is to set the layer's maxResolution
option to one of the map resolution values. For the purposes of these
instructions, set it to 4.23334180001693 as:
{{{
var overlayLayer =
new OpenLayers.Layer.ArcGISCache('Roads', roadsUrl, {
tileOrigin: agsTileOrigin,
maxResolution: 4.23334180001693, //resolutions: mapResolutions,
sphericalMercator: true,
maxExtent: mapExtent,
useArcGISServer: false,
isBaseLayer: false,
projection: proj
});
}}}
3. Display the HTML in a browser and notice that the map no longer
displays the roads layer on start-up and the LayerSwitcher control shows
that while the layer is currently on, it is not visible at the start-up
resolution. This is expected and the desired behaviour.
4. Zoom one level further into the map so you are now at the maximum
resolution where the roads overlaylayer should be visible. The layer's
tiles are not displayed.
The reason the tiles are not displayed is because the URLs determined by
the Layer.ArcGISCache class' getURL method are incorrect. They are
incorrect because it is using the wrong resolution to determine the path.
The getURL method assumes the ArcGISCache layer will always have the same
number of resolutions as the map (really, the baselayer), which is not a
safe assumption. Application designers will often want to limit the
visibility of overlay layers to make the map easier to read and comprehend
at various scales (as discussed at:
http://trac.osgeo.org/openlayers/wiki/SettingZoomLevels).
To fix the problem:
1. Change the initialization of the res variable in the Layer.ArcGISCache
class' getURL method from this.getResolution() to
this.map.getResolution().
{{{
getURL: function (bounds) {
var res = this.map.getResolution(); //var res = this.getResolution();
// tile center
:
}
}}}
2. Reload the HTML page in the browser and zoom one level further into the
map.
The URLs are now determined properly and the tiles should appear in the
map.
--
Ticket URL: <http://trac.openlayers.org/ticket/3633>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer
More information about the Trac
mailing list