GeoJSONSource
定义于: src/source/geojson_source.ts:105
一个包含GeoJSON数据的数据源;有关选项的详细文档,请参见GeoJSONSourceOptions;
示例
// 添加到地图
map.addSource('some id', {
type: 'geojson',
data: 'https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_10m_ports.geojson'
});
// 更新
let mySource = map.getSource('some id');
mySource.setData({
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": { "name": "Null Island" },
"geometry": {
"type": "Point",
"coordinates": [ 0, 0 ]
}
}]
});
map.removeSource('some id'); // 移除
实现
- Source
方法
getClusterChildren()
getClusterChildren(
clusterId
: number,callback
: Function):this
定义于: src/source/geojson_source.ts:333
获取给定的集群的子项;
参数
参数 | 类型 | 描述 |
---|---|---|
clusterId | number | 集群的id |
callback | Function | 一个回调函数,用于接收集群的子项;函数的参数为error 和features ,其中features 是一个包含子集群和点的数组 |
返回
this
getClusterExpansionZoom()
getClusterExpansionZoom(
clusterId
: number,callback
: Function):this
定义于: src/source/geojson_source.ts:370
获取展开给定集群需要的缩放级别;
参数
参数 | 类型 | 描述 |
---|---|---|
clusterId | number | 集群的id |
callback | Function | 一个回调函数,用于接收集群扩展所需的缩放级别;函数的参数为error 和zoom |
返回
this
getClusterLeaves()
getClusterLeaves(
clusterId
: number,limit
: number,offset
: number,callback
: Function):this
定义于: src/source/geojson_source.ts:350
获取给定集群的叶子项;
参数
参数 | 类型 | 描述 |
---|---|---|
clusterId | number | 集群的id |
limit | number | 返回的最大要素数量,默认值为10 |
offset | number | 数据中的结果偏移量,默认值为0 |
callback | Function | 一个回调函数,用于接收集群的子项;函数的参数为error 和features |
返回
this
loaded()
loaded():
boolean
定义于: src/source/geojson_source.ts:312
如果数据已加载,则返回true;
返回
boolean
setData()
setData(
data
: GeoJSON.GeoJSON | string | undefined):this
定义于: src/source/geojson_source.ts:243
设置GeoJSON数据并重新渲染地图;
参数
参数 | 类型 | 描述 |
---|---|---|
data | GeoJSON.GeoJSON | string | undefined | 用于设置数据属性的GeoJSON对象或URL |
返回
this
source