我一整天都在這裏,誠實地說我已經沒有想法了。我有一些WMS圖層,我想根據當前縮放級別顯示/不顯示。是的,我已經通過了API文檔,他們似乎很清楚白天,但我遵循一切建議,我沒有得到所需的結果:(根據縮放級別顯示WMS圖層
這是我看到的來源之一: http://trac.osgeo.org/openlayers/wiki/SettingZoomLevels
然後爲了讓事情變得更糟我發現如果你有一個打開的街道地圖基礎層顯示在加載它似乎限制你的控制權地圖的numZoomLevels,正是我所需要的,因爲我想用它作爲我的加載基礎層...
所以我的問題是:
我在做什麼錯? 在負載上使用開放式街道地圖基礎圖層時,確實沒有關於縮放級別控制的解決方法嗎?還是有什麼我不知道的?
下面是我的一些代碼嘗試: 採取1:tib_villages層應該只顯示縮放級別爲8-10時,不起作用!
var options = {
controls: [new OpenLayers.Control.Navigation()], //Needed to use GeoExt controls such as the zoomslider
maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
units: 'm',
numZoomLevels: null, //setting the map's zoom levels to null
allOverlays: false
}
var osm = new OpenLayers.Layer.OSM(); //MY base layer
//MY overlay layer
var tib_villages = new OpenLayers.Layer.WMS(
"Villages", "http://localhost:8080/geoserver/wms", {layers: 'cite:tib_villages', transparent: true, numZoomLevels: 10, minZoomLevel: 8}, {isBaseLayer: false, displayInLayerSwitcher: true, visibility: true}
);
以2:當縮放級別爲8-10 tib_villages層應僅顯示,地圖應該只有10個縮放級別,而是具有19開放街道地圖圖層強制執行它,不工作!
var options = {
controls: [new OpenLayers.Control.Navigation()], //Needed to use GeoExt controls such as the zoomslider
maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
units: 'm',
numZoomLevels: 10, //setting the map's zoom levels to 10 only
allOverlays: false
}
var osm = new OpenLayers.Layer.OSM(); //MY base layer
//MY overlay layer
var tib_villages = new OpenLayers.Layer.WMS(
"Villages", "http://localhost:8080/geoserver/wms", {layers: 'cite:tib_villages', transparent: true, numZoomLevels: null, minZoomLevel: 8}, {isBaseLayer: false, displayInLayerSwitcher: true, visibility: true}
)
;採取3:在加載時擺脫了開放街道地圖基礎圖層後,地圖只有10個縮放級別,但tib_villages圖層只應在縮放級別爲8-10時顯示,不起作用!
var options = {
controls: [new OpenLayers.Control.Navigation()], //Needed to use GeoExt controls such as the zoomslider
maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
units: 'm',
numZoomLevels: 10, //setting the map's zoom levels to 10
allOverlays: false
}
//MY overlay layer
var tib_villages = new OpenLayers.Layer.WMS(
"Villages", "http://localhost:8080/geoserver/wms", {layers: 'cite:tib_villages', transparent: true, numZoomLevels: 10, minZoomLevel: 8}, {isBaseLayer: false, displayInLayerSwitcher: true, visibility: true}
);
您的所有建議都衷心感謝!
elshae
** @ elshae **:我會在http://gis.stackexchange.com/或郵件列表*[email protected]*上發佈您的問題。 – Chau 2010-10-25 07:32:12
嗯,我會去看看gis.stackexchange.com,我會在[email protected]上發帖,但我經常沒有迴應: -/ – elshae 2010-10-25 13:52:34