ImageSource
定义于: src/source/image_source.ts:93
包含图像的数据源;有关选项的详细文档,请参见ImageSourceSpecification;
示例
// 添加到地图
map.addSource('some id', {
type: 'image',
url: 'https://www.mapbox.com/images/foo.png',
coordinates: [
[-76.54, 39.18],
[-76.52, 39.18],
[-76.52, 39.17],
[-76.54, 39.17]
]
});
// 更新
var mySource = map.getSource('some id');
mySource.setCoordinates([
[-76.54335737228394, 39.18579907229748],
[-76.52803659439087, 39.1838364847587],
[-76.5295386314392, 39.17683392507606],
[-76.54520273208618, 39.17876344106642]
]);
map.removeSource('some id'); // 移除
实现
- Source
方法
getCoordinates()
getCoordinates(): Coordinates
定义于: src/source/image_source.ts:201
返回地图纬度/经度边界;
返回
Coordinates
图像边界,格式为[[西北坐标],[东北坐标],[东南坐标],[西南坐标]];
listens()
listens(
type
: string): boolean
定义于: src/util/evented.ts:165
如果此Evented实例或其任何转发的Evented实例为指定类型注册了监听器,则返回true;
参数
参数 | 类型 | 描述 |
---|---|---|
type | string | 事件类型 |
返回
boolean
如果为指定的事件类型注册了至少一个监听器,则返回true
,否则返回false
;
loaded()
loaded(): boolean
定义于: src/source/image_source.ts:163
如果源已加载,则为true,否则为false;
返回
boolean
loadTile()
loadTile(
tile
: Tile): Promise<void>
定义于: src/source/image_source.ts:275
此方法完成加载图块的繁重工作;在大多数情况下,它会将工作委托给相关的工作器源(worker source);
参数
参数 | 类型 | 描述 |
---|---|---|
tile | Tile | 要加载的图块 |
返回
Promise<void>
off()
off(
type
: string,listener
: Listener): ImageSource
定义于: src/util/evented.ts:90
移除先前注册的事件监听器;
参数
参数 | 类型 | 描述 |
---|---|---|
type | string | 要移除监听器的事件类型 |
listener | Listener | 要移除的监听器函数 |
返回
ImageSource
on()
on(
type
: string,listener
: Listener): Subscription
定义于: src/util/evented.ts:73
为指定的事件类型添加监听器;
参数
参数 | 类型 | 描述 |
---|---|---|
type | string | 要添加监听的事件类型 |
listener | Listener | 事件触发时要调用的函数;监听器函数使用传递给fire的数据对象调用,该对象扩展了target和type属性 |
返回
Subscription
once()
once(
type
: string,listener?
: Listener): Promise<any> | ImageSource
定义于: src/util/evented.ts:106
添加一个只会被调用一次的监听器到指定的事件类型;
监听器将在注册后事件首次触发时被调用;
参数
参数 | 类型 | 描述 |
---|---|---|
type | string | 要监听的事件类型 |
listener? | Listener | 事件首次触发时要调用的函数 |
返回
Promise<any> | ImageSource
如果没有提供监听器,则返回this
或一个promise;
setCoordinates()
setCoordinates(
coordinates
: Coordinates): this
定义于: src/source/image_source.ts:215
设置图像的坐标并重新渲染地图;
参数
参数 | 类型 | 描述 |
---|---|---|
coordinates | Coordinates | 四个地理坐标,表示为经度和纬度数字的数组,定义图像的角;坐标从图像的左上角开始,按顺时针方向排列;它们不必表示一个矩形 |
返回
this
setEventedParent()
setEventedParent(
parent?
: Evented,data?
: any): ImageSource
定义于: src/util/evented.ts:176
将此Evented实例触发的所有事件冒泡到此父Evented实例;
参数
参数 | 类型 | 描述 |
---|---|---|
parent? | Evented | |
data? | any |
返回
ImageSource
updateImage()
updateImage(
options
: UpdateImageOptions): this
定义于: src/source/image_source.ts:173
更新图像URL,并可选择更新坐标;为避免更改后图像闪烁,请将栅格图层上的raster-fade-duration
绘制属性设置为0;
参数
参数 | 类型 | 描述 |
---|---|---|
options | UpdateImageOptions | 选项对象 |
返回
this
属性
id
id: string
定义于: src/source/image_source.ts:94
源的ID;不能被任何现有源使用;
maxzoom
maxzoom: number
定义于: src/source/image_source.ts:96
源的最大缩放级别;
minzoom
minzoom: number
定义于: src/source/image_source.ts:95
源的最小缩放级别;
terrainTileRanges
terrainTileRanges: object
定义于: src/source/image_source.ts:103
此对象用于存储与此图块重叠的地形图块范围;对于图像图块很重要,因为图像超出了单个图块边界;
索引签名
[zoom
: string]: CanonicalTileRange
tileSize
tileSize: number
定义于: src/source/image_source.ts:97
源的图块大小;