首页 > Web开发 > 详细

leaflet 加载geojson叠加显示

时间:2020-02-17 15:59:00      阅读:335      评论:0      收藏:0      [点我收藏+]

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 });

将地图的视野范围添加到相应区域。

leaflet 加载geojson叠加显示

原文:https://www.cnblogs.com/tiandi/p/12321413.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!