0
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.

  • Welcome to GIS.SE forum. Which software you are using ? – Sunil May 27 '13 at 8:35
0

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

1

You Can Use minScale and maxScale within each vector layer as below.

var options = 
{
    scales: [50000, 100000, 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()],
    minScale:1/150000,
    maxScale:1/100000,
    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" 
    })
});
0

After you have created the map you can use this function to get the scales at different zoomlevels:

map.events.register('zoomend', this, function (event) {
   var zLevel = map.getZoom();
   var sc = map.getScale();
   document.getElementById('MatrikelOutput').innerHTML = "Level: " + zLevel + " Scale: " + sc;     
});

The result could be: "Level 11 Scale 2000". Choose your start and stop zoomlevels and then set them in the layer options:

    minScale: 1/10000,
    maxScale: 1/2000

Remark that the scale is defined by 1 divided by the scale returned by map.getScale()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.