我試圖在使用ArcGIS Javascript API 3.17的幾個自定義底圖上實現詳細圖層(LOD)。其中一個用於較少細節,另外兩個用於更多細節,但覆蓋不同的區域。我遇到了問題,但頁面未加載(對於Firefox和IE)。任何人都可以看到我不是什麼?請注意,我在這裏使用了一些示例服務。另外,我在我的真實實施中添加了一些動態要素圖層,我沒有在這裏列出。使用ArcGIS Javascript API設置自定義底圖的詳細級別3.17
var map;
var extent;
var baseMapLayerPPT;
var baseMapLayerPoly;
var customLods = [];
var loadCount = 0;
require([
"esri/geometry/Extent","esri/map", "esri/dijit/Search", "esri/layers/ArcGISDynamicMapServiceLayer","esri/layers/FeatureLayer", "esri/InfoTemplate", "dojo/domReady!"
], function (Extent, Map, Search, DynamicMapServiceLayer, FeatureLayer, InfoTemplate) {
baseMapLayerPoly = new esri.layers.ArcGISTiledMapServiceLayer("https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer", {
displayLevels: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
});
baseMapLayerPoly.on("load", addLods);
baseMapLayerPPT = new ArcGISTiledMapServiceLayer("https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer", {
displayLevels: [11, 12, 13, 14, 15 ],
//opacity : 0.75
});
extent = new esri.geometry.Extent({
"xmin":-91070.37,"ymin":7988806.64,"xmax":301214.62,"ymax":8227343.05,
"spatialReference":{"wkid":3297}
});
// popuplate an array with zoom levels
function addLods(evt) {
customLods = customLods.concat(evt.layer.tileInfo.lods);
loadCount++;
if (loadCount === 2) {
initMap();
}
}
// create the map and use the custom zoom levels
function initMap() {
map = new Map("mapDiv", {
center: [-150, -17],
zoom: 9,
lods : customLods
});
map.on("extent-change", changeScale);
map.addLayers([baseMapLayerPoly,baseMapLayerPPT);
}
//Report which layer is being shown
function changeScale(evt) {
dom.byId("scale").innerHTML = "Level: <i>" + evt.lod.level;
if (evt.lod.level < 11) {
dom.byId("visibleLayer").innerHTML = "Layer: <i>Imagery</i>";
} else if (evt.lod.level == 11) {
// both layers are loaded
dom.byId("visibleLayer").innerHTML = "<i>Both layers currently visible</i>";
} else {
dom.byId("visibleLayer").innerHTML = "Layer: <i>Streets</i>";
}
}
});
我覺得你的代碼是不完整的,功能'addLods'只調用一次,所以'initMap'不會被調用。請用正確的代碼編輯。 –
你可以爲它創建jsfiddle ... –
添加完整的代碼atleast ..以及HTML和所有.. –