1. geojson数据:https://blog.csdn.net/weixin_38307752/article/details/84112566
2. 简单要素的添加:https://blog.csdn.net/xcymorningsun/article/details/83409568
二、简单要素点线面的添加
1、创建feature
2、创建style,添加source、style到layer
3、添加layer到map
通过WFS服务获取geojson数据,然后将整个geojson数据加载到vectorlayer图层中去,不过这种方法有个缺点就是不能实现自定义加载各种数据。如果需要对geojson数据中的属性进行修改添加的时候不容易控制(这在以后为每个feature在地图上同时添加气泡框功能有帮助),然后有了这篇文章。
1、创建feature
>>参考:esri-leaflet:
var loadData = function (){
$.ajax(url_link, {//leaflet/data/MegaCities.geojson //url_link //'leaflet/data/arcgis_json.json'
dataType: "json",
success: function(response){
geojson1 = L.esri.Util.arcgisToGeoJSON(response);
geoJSONLayer = L.geoJSON(geojson1);//,{onEachFeature:popUp}
//geoJSONLayer.addTo(map);
//第二种添加方法
for(var i in geojson1.features){
//alert(i);//geojson1.features[i]
DTmap[i] = L.geoJSON(geojson1.features[i],{//response
style:function(feature){
return{
color:'#FF0000',
fillOpacity: 0.2,
weight:3,
dashArray:'10'
};
}
}).bindTooltip("<div id='table'><ul><li>"+geojson1.features[i].properties.OBJECTID+"</li><li>" + "</li><li>",{
direction:'top'
}).on({
mouseover: highlight, //鼠标移动上去高亮
mouseout: resetHighlight, //鼠标移出恢复原样式
click: zoomTo //点击最大化
}).addTo(cities);
}
}
});
}