Cesium入門6 - Adding Imagery - 添加圖層


Cesium入門6 - Adding Imagery - 添加圖層

Cesium中文網:http://cesiumcn.org/ | 國內快速訪問:http://cesium.coinidea.com/

Cesium應用程序另一個關鍵元素是Imagery(圖層)。瓦片圖集合根據不同的投影方式映射到虛擬的三維數字地球表面。依賴於相機指向地表的方向和距離,Cesium會去請求和渲染不同層級的圖層詳細信息。

多種圖層能夠被添加、移除、排序和適應到Cesium中。

Cesium提供了一系列方法用於處理圖層,比如顏色自適應,圖層疊加融合。一些樣例代碼如下:

Cesium提供了各種接口支持各樣的圖層數據源。

支持的圖層格式

  1. wms
  2. TMS
  3. WMTS (with time dynamic imagery)
  4. ArcGIS
  5. Bing Maps
  6. Google Earth
  7. Mapbox
  8. OpenStreetMap

注意:不同的數據源需要不同的認證 - 需要確保自己能夠有權限訪問到這些數據源,自然地需要注冊特定的認證才可以

默認地,Cesium使用Bing Maps作為默認的圖層。這個圖層被打包進Viewer中用於演示。Cesium需要您自己創建ion account然后生成一個access key用於訪問圖層數據。

在接下來的例子中,將使用Cesium ion中的Sentinel-2圖層。

  1. 去Cesium ion頁面,將Sentinel-2圖層加入到自己的assets中。點擊在導航欄中點擊“Asset Depot”

  2. 點擊“Add to my assets”。Sentinel-2將在你個人用戶中的asset列表(My Assets)中出現,此時將在個人的app中圖層數據源變得可用。

  3. 代碼級別:我們創建一個IonImageryProvider,將assetId傳給對應的Sentinel-2圖層。然后我們將ImageryProvider添加到viewer.imageryLayers

// Remove default base layer
viewer.imageryLayers.remove(viewer.imageryLayers.get(0));

// Add Sentinel-2 imagery
viewer.imageryLayers.addImageryProvider(new Cesium.IonImageryProvider({ assetId : 3954 }));

基於上述的代碼,我們的Cesium應用程序在縮進zoom in的時候會看到如下圖層:

關於圖層的更多信息:請訪問Imagery Layers Tutorial

Cesium中文網交流QQ群:807482793

Cesium中文網:http://cesiumcn.org/ | 國內快速訪問:http://cesium.coinidea.com/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM