标注图层
支持图层属性标注。

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>标注图层</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<style>
body {
margin: 0;
padding: 0;
}
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
color: rgb(189, 187, 97);
}
</style>
<script src="https://delivery.mapmost.com/cdn/sdk/webgl/v9.4.0/mapmost-webgl-min.js"></script>
</head>
<body>
<div id="map"></div>
<script>
let map = new mapmost.Map({
container: 'map',
style: "<your style url>",
center: [120.72200705967907, 31.325916955090918],
zoom: 16.453384636607698,
pitch: 3.7867872269025664,
bearing: 0,
userId: '***', // 授权码
});
map.on('load', function () {
map.addSource('roadCross', {
"type": "geojson",
data: "../example_data/camera.geojson"
})
map.addLayer({
"id": "roadcross",
"type": 'circle',
"source": "roadCross",
"layout": {
},
"paint": {
'circle-radius': 8,
'circle-color': "rgb(221, 219, 105)"
}
})
map.addLayer({
"id": "roadCross",
"type": 'symbol',
"source": "roadCross",
"layout": {
"text-field": ['get', 'SBMC'],
// 文本的顶部放置在最靠近锚点的位置
"text-variable-anchor": ["top"]
},
"paint": {
'text-color': "#000000"
}
})
})
</script>
</body>
</html>