leaflet 加載geojson疊加顯示


geojson需要先制作shp,然后導入下面網站生成geojson。

https://mapshaper.org/

geojson,最好放后台,前台通過異步請求去加載json,然后顯示。

 

getGeojsonByName({name:geojson_name}).then(data=>{
          if (this.bondarylayer) {
            if (this.map.hasLayer(this.bondarylayer))
            {
              this.map.removeLayer(this.bondarylayer);
            }
          }
          this.bondarylayer = L.geoJSON(data, {
            style: {
              color: '#E066FF',
              fillOpacity: 0,
              weight: 4,
            },
            pane: 'overlayPane'
          });
          this.map.addLayer(this.bondarylayer);
        });

     疊加地圖之后,

this.map.flyTo([34.22, 109.114], 9, { animate: true, duration: 0.2 });

將地圖的視野范圍添加到相應區域。


免責聲明!

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



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