Sunday, 26 November 2017

openlayers 2 - maxScale or minScale don't work in vector (from WFS) layer


var options = 
{
projection: "EPSG:900913",
displayProjection: "EPSG:4326",
units: 'm'
};
map = new OpenLayers.Map('map', options);

ilceSinir = new OpenLayers.Layer.Vector("İlçe Sınırı",

{
minScale: 150000,
strategies: [new OpenLayers.Strategy.Fixed()],
projection: new OpenLayers.Projection("EPSG:4326"),
protocol: new OpenLayers.Protocol.WFS(
{
version: "1.1.0",
url: "http://localhost:8080/geoserver/wfs",
featurePrefix: 'topp',
featureType: "g_ilce_siniri",

featureNS: "http://www.openplans.org/topp",
geometryName: "bounds"
})
});

Scale isn't working, layer is visible at every zoom.



Answer



how about this:


var options = 
{

scales: [50000, 100000, 150000],
minScale: 150000,
projection: "EPSG:900913",
displayProjection: "EPSG:4326",
units: 'm'
};
map = new OpenLayers.Map('map', options);

ilceSinir = new OpenLayers.Layer.Vector("İlçe Sınırı",
{

strategies: [new OpenLayers.Strategy.Fixed()],
projection: new OpenLayers.Projection("EPSG:4326"),
protocol: new OpenLayers.Protocol.WFS(
{
version: "1.1.0",
url: "http://localhost:8080/geoserver/wfs",
featurePrefix: 'topp',
featureType: "g_ilce_siniri",
featureNS: "http://www.openplans.org/topp",
geometryName: "bounds"

})
});

source: http://trac.osgeo.org/openlayers/wiki/SettingZoomLevels


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...