//针对的是mapbox加载geojson的数据格式去渲染点线面
首先说说source的类型有哪些:
source的类型有:
1.type: "geojson" (点(circle)线(line)面(fill)图标(symbol))【map.getSource('geojson').setData(geojson)给数据源赋值】
2.type: "image" (图片)【map.getSource("radar").updateImage({ url: getPath() });】
3.type: 'canvas',
4.type: "raster", (瓦片WMS 服务加载)
下面的代码着重写的是geojson格式的数据源渲染点线面,代码如下:
//申明一个变量
var geojson = {
"type": "FeatureCollection",
"features": []
};
//加载source数据源
map.addSource('geojson', {
"type": "geojson",
"data": geojson
});
//点
map.addLayer({
id: 'measure-points',
type: 'circle',
source: 'geojson',
paint: {
'circle-radius': 5,