SuperMap IClient for Leaflet 常用Api
draw 原生api
SuperMap IClient 官方网站
Leaflet 原生首页
Leaflet 原生api 全英文
// 常用Api
// map 地图实例 arr [0,0]
map.flyTo(arr) // 坐标点定位
//无需加载draw 即可调用画图方法
new L.Draw.Marker(map, drawControl.options.marker).enable()
new L.Draw.Polygon(map, drawControl.options.polygon).enable()
new L.Draw.Polyline(map, drawControl.options.polyline).enable()
// draw 操作
editableLayers = new L.FeatureGroup()
map.on(L.Draw.Event.CREATED, function (e) {
if (layerObj) {
// 执行工具栏功能 清除上一次操作
editableLayers .removeLayer(layerObj)
// 然后清空保存的对象
layerObj = null
}
var type = e.layerType,
layer = e.layer;
if (type === 'marker') {
layer.bindPopup('A popup!');
}
editableLayers.addLayer(layer);
// 保存当前layer
layerObj= layer
let data = layer.toGeoJSON()
});
// 清除 layer
// arr = []
var ico = L.icon({
iconUrl: 'images/a.png',
iconSize: [28, 32],
iconAnchor: [16, 9]
});
let marker = L.marker(arr, {icon: ico})
let resultLayer = L.featureGroup().addTo(map).addLayer(marker);
resultMarkArr = resultLayer
map.removeLayer(resultMarkArr )