GeoJSONSource
GeoJSON数据源。 继承Evented。
示例
map.addSource('some id', {
type: 'geojson',
data: 'https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_10m_ports.geojson'
});
map.addSource('some id', {
type: 'geojson',
data: {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
116.45,
39.9
]
}
}]
}
});
map.getSource('some id').setData({
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": { "name": "Null Island" },
"geometry": {
"type": "Point",
"coordinates": [ 116.45, 39.9 ]
}
}]
});
方法
方法 | 返回值 | 描述 |
---|---|---|
setData(data: object | string ) | this | 指定GeoJSON数据或URL,并将数据渲染在地图上 |
getClusterExpansionZoom (clusterId:number,callback:Callback< number >) | this | |
getClusterChildren (clusterId:number,callback:Callback< number >) | this | |
getClusterLeaves (clusterId:number , limit:number , offset:number , callback:Callback< number >) | this |