I am using OpenLayers 2 and Geoserver.
I have a few WFS layers and an OpenStreetMap as a Baselayer. I want to change the vector layers' visibility at certain zoom levels, by using min/maxScale or min/maxResolution, but it doesn't seem to work. In the following example I use only one of the layers as a test.
My code using min/maxScale:
If I use min/max Scale nothing happens, the layers are visible at all zoom levels. Also, in the browser Console I see that the units didn't change, even if I specified "meters" in my options, I still see that "degrees" are used.
And my code using min/maxResolution:
//Basemap var osm = new OpenLayers.Layer.OSM("Simple OSM Map"); map.addLayer(osm); //Layer var test = new OpenLayers.Layer.Vector("xName", { strategies: [new OpenLayers.Strategy.Fixed(), saveStrategy], minResolution: 14.035643, maxResolution: 7.01782148, protocol: new OpenLayers.Protocol.WFS({ url: SETTINGS.BASE_URL, featurePrefix: 'xNS', featureNS: "xNS", //extractAttributes: true, featureType: "xName", }), styleMap: new OpenLayers.StyleMap({ "default": new OpenLayers.Style({ "pointRadius": 2, fill: true, fillColor: "#8d006a", strokeColor: "#000000", strokeWidth: 0.2 }) }) }); //Add Layer map.addLayer(test); When using min/maxResolution, the layers are no longer visible at any zoom level. They can be seen on the LayerSwitcher but cannot be selected. I suppose that at a certain resolution (the one specified) they should be visible and selectable, but that's not the case.
Thank you all in advance.
Raluca
أكثر...
I have a few WFS layers and an OpenStreetMap as a Baselayer. I want to change the vector layers' visibility at certain zoom levels, by using min/maxScale or min/maxResolution, but it doesn't seem to work. In the following example I use only one of the layers as a test.
My code using min/maxScale:
If I use min/max Scale nothing happens, the layers are visible at all zoom levels. Also, in the browser Console I see that the units didn't change, even if I specified "meters" in my options, I still see that "degrees" are used.
And my code using min/maxResolution:
//Basemap var osm = new OpenLayers.Layer.OSM("Simple OSM Map"); map.addLayer(osm); //Layer var test = new OpenLayers.Layer.Vector("xName", { strategies: [new OpenLayers.Strategy.Fixed(), saveStrategy], minResolution: 14.035643, maxResolution: 7.01782148, protocol: new OpenLayers.Protocol.WFS({ url: SETTINGS.BASE_URL, featurePrefix: 'xNS', featureNS: "xNS", //extractAttributes: true, featureType: "xName", }), styleMap: new OpenLayers.StyleMap({ "default": new OpenLayers.Style({ "pointRadius": 2, fill: true, fillColor: "#8d006a", strokeColor: "#000000", strokeWidth: 0.2 }) }) }); //Add Layer map.addLayer(test); When using min/maxResolution, the layers are no longer visible at any zoom level. They can be seen on the LayerSwitcher but cannot be selected. I suppose that at a certain resolution (the one specified) they should be visible and selectable, but that's not the case.
Thank you all in advance.
Raluca
أكثر...