[OpenLayers-Dev] OpenLayers 2.11 loading layer data regardless of
maxResolution
Ruben Schoenefeld
rschoenefeld at utah.gov
Thu May 3 16:36:02 EDT 2012
Hi -
I have been using OpenLayers 2.10 / GeoExt 1.0 / ExtJS 3.2.1 for a while now and decided it's time to upgrade to OpenLayers 2.11. Ever since I did, I have a problem with my two (mutually exclusive) overlays. Here's how I created them:
l_layer_route = new OpenLayers.Layer.Vector
( "Utah State Routes"
, { "strategies":
[ new OpenLayers.Strategy.BBOX()
]
, "protocol": new OpenLayers.Protocol.WFS(
{ "version": '&G_WFSVERSION.'
, "srsName": 'EPSG:26912'
, "url": '&G_WFSMAP.'
, "featureType": '&G_WFS_ROUTE.'
, "featureNS": '&G_GEOSERV_NAMESPACE.'
, "geometryName": 'GEOM'
})
, "visibility": true
, "styleMap": l_style_route
, "minResolution": 0.298582153289307
, "maxResolution": 20
, "units": 'm'
, "alwaysInRange": false
}
);
l_layer_centerline = new OpenLayers.Layer.Vector
( "Local Street Centerlines"
, { "strategies":
[ new OpenLayers.Strategy.BBOX()
]
, "protocol": new OpenLayers.Protocol.WFS(
{ "version": '&G_WFSVERSION.'
, "srsName": 'EPSG:26912'
, "url": '&G_WFSMAP.'
, "featureType": '&G_WFS_CENTERLINE.'
, "featureNS": '&G_GEOSERV_NAMESPACE.'
, "geometryName": 'GEOM'
})
, "visibility": false
, "styleMap": l_style_centerline
, "minResolution": 0.298582153289307
, "maxResolution": 4
, "units": 'm'
, "alwaysInRange": false
}
);
The locations in the WFS protocol entries are populated when the page is run. The routes layer contains fewer records "per area" than the street centerline layer, so it should be okay to display it at 20 m / pixel. The centerline layer should be displayed at 4 m / pixel. I've got the following resolutions on the map, which come from the first base map that I add:
[4891.96999883583, 2445.98499994708, 1222.99250010583, 611.496250052917, 305.748124894166, 152.8740625, 76.4370312632292, 38.2185156316146, 19.1092578131615, 9.55462890525781, 4.77731445262891, 2.38865722657904, 1.19432861315723, 0.597164306578613, 0.298582153289307]
When I initially load the map, the resolution is 1222.99250010583 m / pixel, to display the whole state of Utah. The extent of the map on my screen is -296596.91381471, 3855627.9299551, 1199122.9138147, 4892725.5700449.
All the layers (base maps and overlays) use the EPSG:26912 projection.
So from that, as expected, neither the routes or centerline layers are loaded, which is great and as I expect it. As you can see in the layer definition for the routes layer (the first of the two), its visibility is "true" when the layer is created. Yesterday, more or less on accident, I used the layer switcher to switch from the routes layer to the centerline layer, which happens by executing this:
l_layer_route.setVisibility(false);
l_layer_centerline.setVisiblity(true);
This worked fine in OpenLayers 2.10, but since I switched to 2.11, what happens now (while displaying the whole state) is that it first loads all the data for the routes layer of that huge extent, which takes forever and is multiple MB of data and then it loads all the data for the centerline layer, which is too much for Firefox and I get it to crash.
So my questions:
1) Why would OpenLayers want to load the data when maxResolution on the layers clearly tells it that it shouldn't?
2) Why would OpenLayers want to load the data for the routes layer when I am setting its visibility to false but it didn't care to do that when I initially loaded the page (and shouldn't have)?
3) What am I doing wrong?
Because I first experienced this problem with OpenLayers 2.11, I switched back to 2.10 just to see if it happens there, and it didn't. I also upgraded GeoExt to 1.1 now and that doesn't make a difference. Also, initially, I didn't have the minResolution set, but only maxResolution. But I added it now, but that doesn't make a difference.
Please let me know if further information is needed.
Thanks for your help.
Ruben Schoenefeld, Utah Department of Transportation
More information about the Dev
mailing list