# 叠加图标
# 使用示例
<script>
var map = L.map('map', {
crs: L.CRS.CustomEPSG4326,
center: {lon: 121.4302, lat: 28.6024},
zoom: 16,
inertiaDeceleration: 15000,
maxZoom: 20
})
//添加底图
var layer = new L.GVMapGrid(window.leaflet.getDataUrl + '&x={x}&y={y}&l={z}')
map.addLayer(layer)
//添加注记
var labelLayer = new L.GWVTAnno({tileSize: 512})
var dataSource = new Custom.URLDataSource()
dataSource.url = window.leaflet.labelUrl + '&x={x}&y={y}&l={z}'
labelLayer.addDataSource(dataSource)
map.addLayer(labelLayer)
var greenIcon = L.icon({
iconUrl: 'https://ditu.zjzwfw.gov.cn/docs/vectormap/img/flag.png',
iconSize: [70, 95], // size of the icon
iconAnchor: [4, 47],
})
L.marker(map.getCenter(), {icon: greenIcon}).addTo(map) //图片点,固定大小
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
运行结果