日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 前端技术 > javascript >内容正文

javascript

ArcGIS JS先添加动态图层,再添加切片图层后不显示

發(fā)布時(shí)間:2025/3/21 javascript 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ArcGIS JS先添加动态图层,再添加切片图层后不显示 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

場(chǎng)景:

? ? ? ? ?現(xiàn)在要在一個(gè)地圖上添加動(dòng)態(tài)服務(wù)圖層和切片服務(wù)圖層,當(dāng)創(chuàng)建好圖層之后,使用map.addLayer()方法,先把動(dòng)態(tài)圖層加到地圖上,再把切片圖層加到地圖上,出現(xiàn)一個(gè)現(xiàn)象:只能看到加載的動(dòng)態(tài)圖層,切片圖層沒了。

現(xiàn)象:

先加載動(dòng)態(tài)圖層,再加載切片圖層

所對(duì)應(yīng)代碼:

<script>var map;require(["esri/map","esri/layers/ArcGISDynamicMapServiceLayer","esri/layers/ArcGISTiledMapServiceLayer"], function (Map, ArcGISDynamicMapServiceLayer,ArcGISTiledMapServiceLayer) {map = new Map("mapDiv");//動(dòng)態(tài)地圖服務(wù)圖層var dynamic = new ArcGISDynamicMapServiceLayer("https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer");//切片地圖服務(wù)圖層var tiled = new ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer");//先添加動(dòng)態(tài)地圖服務(wù)//If the first layer added to the map is an ArcGISDynamicMapServiceLayer,// the map will take on the projection of this layer.map.addLayer(dynamic);//再添加切片地圖服務(wù)map.addLayer(tiled);}); </script>

解決方法:

試了試,先添加切片圖層,再添加動(dòng)態(tài)圖層,就沒有什么問題了,兩個(gè)圖層都可以疊加到地圖上面。主要代碼如下:

<script>var map;require(["esri/map","esri/layers/ArcGISDynamicMapServiceLayer","esri/layers/ArcGISTiledMapServiceLayer"], function (Map, ArcGISDynamicMapServiceLayer,ArcGISTiledMapServiceLayer) {map = new Map("mapDiv");//動(dòng)態(tài)地圖服務(wù)圖層var dynamic = new ArcGISDynamicMapServiceLayer("https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer");//切片地圖服務(wù)圖層var tiled = new ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer");// //先添加動(dòng)態(tài)地圖服務(wù)// //If the first layer added to the map is an ArcGISDynamicMapServiceLayer,// // the map will take on the projection of this layer.// map.addLayer(dynamic);// //再添加切片地圖服務(wù)// map.addLayer(tiled);//改變順序,先添加切片圖層,再添加動(dòng)態(tài)圖層map.addLayer(tiled);console.log(map.spatialReference);map.addLayer(dynamic);}); </script>

改變添加順序后的效果:
?

? ? ? ? 現(xiàn)在可以看到兩個(gè)圖層已經(jīng)疊起來(lái)了。到底是什么原因呢?

原因分析:

? ? ? ??偶然找到一個(gè)官方的文檔(https://pan.baidu.com/s/1o8UhCxG),里面有這么一段:

? ? ? ? 緩存圖層指的就是切片圖層,如果先添加動(dòng)態(tài)圖層,再添加切片圖層,由于切片圖層不會(huì)動(dòng)態(tài)轉(zhuǎn)換空間參考,導(dǎo)致地圖上只有動(dòng)態(tài)圖層;反之,如果先加載切片圖層,再加載動(dòng)態(tài)圖層,由于動(dòng)態(tài)圖層可以自動(dòng)轉(zhuǎn)換空間參考,因此可以看到兩個(gè)圖層疊在了一起。

總結(jié)

以上是生活随笔為你收集整理的ArcGIS JS先添加动态图层,再添加切片图层后不显示的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。