I use Firefox.
Of what I understand, each time I zoom in or out a map that has a vector layer, the left and top values of the rederer's viewbox are reseted to 0.
I have a WFS layer with a minScale: 49999 in my map. So, the first time I get inRange of my layer, left and top are reset to 0. If I pan, they change their value and if their value is 15000 pixels away from my original left-top, no feature will be drawn.
The problem is if I zoom out of my minScale: 49999, my layer becomes inactive. Zooming out don't reset the left-top values.
So, if I pan to somewhere else and then zoom in until I get inRange of my minScale, my WFS layer shows no features because it's as we didn't zoom at all ( the resolution is the same that the time we zoom out of range ) . But, if I zoom in again once, then the features appear (because the resolution has changed, and left-top are reseted to 0). If I zoom out once, the features are still there.
I think the main problem is at line 103 in Renderer.SVG when it checks if the resolution has changed. Since it didn't because the WFS layer was inactive ( because it was not inRange ) and the resolution didn't change when we zoomed out. After it checks the resolution, if it's the same, it should check if we are out of the 15000 pixel and if we are, it should reset our left and top values :
left = (this.left) - (-extent.left / resolution);
115 top = (this.top) - (extent.top / resolution);
Here's a code snippet that should allow to see the bug. The map will initially zoom in scale 27000 so we can see the WFS features. Zoom out to 0 using the pan zoom bar then zoom in to an other place far from the initial spot (like Montreal city should be enough). When the WFS layer swith to inRange, you'll see nothing. Zoom in again, you'll see it. Zoom out, you'll see it again.
var oMap;
var olHydro, olRoads, olWFSRoads;
function loadmap()
{
var nZoom = 9; // 1 = normal 3=1750000 6=218750 9=27000
var nLon = -188256; // Chicoutimi city longitude
var nLat = 495208; // Chitoutimi city latitude
var sHTML;
var sMSURL = "http://127.0.0.1:8080/cgi-bin/mapserv";
var sMapPath = "/mypath/mymap.map";
var oMapOptions = {
controls: [],
units: 'm',
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(-1100000, -23500, 1100000, 2253500),
projection: new OpenLayers.Projection("EPSG:32198")
};
var oBLParams = { // Base Layer common params
map: sMapPath,
layers : "", // this value must be set for each layer
format: "image/gif"
};
var oBLOptions = { // Base Layer common options
isBaseLayer: true,
singleTile: true,
minScale: 14000000
};
var oOvParams = { // Overlay common params
map: sMapPath,
layers : "", // this value must be set for each layer
transparent: "true",
format: "image/gif"
};
var oOvOptions = { // Overlay common options
isBaseLayer: false,
singleTile: true,
minScale: 4000000 // init minScale value
};
oMap = new OpenLayers.Map( 'map', oMapOptions );
oBLParams.layers = "hydro";
olHydro = new OpenLayers.Layer.MapServer(
"Hydro", sMSURL, oBLParams, oBLOptions );
oOvOptions.minScale = 1000000; // for below overlay layers
oOvParams.layers = "roads";
olRoads = new OpenLayers.Layer.MapServer(
"Roads", sMSURL, oOvParams, oOvOptions );
olRoads.addOptions( {maxScale: 50000} );
olWFSRoads = new OpenLayers.Layer.WFS(
"Roads - WFS",
sMSURL,
{ typename: "roads", map: sMapPath },
{
extractAttributes: true,
minScale: 49999,
typename: "roads"
}
);
// add layers
oMap.addLayers([olHydro, olRoads, olWFSRoads]);
// add controls
oMap.addControl(new OpenLayers.Control.Navigation());
oMap.addControl(new OpenLayers.Control.Scale($('scale')));
oMap.addControl(new OpenLayers.Control.LayerSwitcher());
oMap.addControl(new OpenLayers.Control.PanZoomBar());
// initial zoom
oMap.zoomToMaxExtent();
oMap.setCenter(new OpenLayers.LonLat(nLon, nLat), nZoom);
}
Alexandre Dube
Mapgears
adube@mapgears.com