# 天地圖添加自定義圖層


天地圖添加自定義圖層

這個其實很簡單哈,官網給的資料挺詳細的,自己去查一下然后直接粘貼過來用就可以了。

添加 WMS 圖層

      addWMS(layers, url) {
        var config = {
          version: "1.1.0",	//請求服務的版本
          layers: layers,
          transparent: true,	//輸出圖像背景是否透明
          styles: "",			//每個請求圖層的用","分隔的描述樣式
          format: "image/png",	//輸出圖像的類型
        };
        if (wmsLayer) {
          map.removeLayer(wmsLayer);
        }
        wmsLayer = new T.TileLayer.WMS(url, config);
        map.addLayer(wmsLayer);
      },

	// 然后調用
	this.addWMS('wjw:test', 'http://localhost:8080/geoserver/wjw/wms')

添加 WMTS 圖層

	let imageURL = "http://localhost:8080/geoserver/gwc/service/wmts?layer=china%3AL10&style=&tilematrixset=WebMercatorQuad&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fpng&TileMatrix={z}&TileCol={x}&TileRow={y}"
        //創建自定義圖層對象
        let lay = new T.TileLayer(imageURL, { minZoom: 1, maxZoom: 18 });
        //將圖層增加到地圖上
        map.addLayer(lay);


免責聲明!

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



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