CanvasSource
定义于: src/source/canvas_source.ts:66
包含HTML画布内容的数据源;有关选项的详细文档,请参阅CanvasSourceSpecification;
示例
// 添加到地图
map.addSource('some id', {
type: 'canvas',
canvas: 'idOfMyHTMLCanvas',
animate: true,
coordinates: [
[-76.54, 39.18],
[-76.52, 39.18],
[-76.52, 39.17],
[-76.54, 39.17]
]
});
// 更新
let 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'); // 移除
继承
- ImageSource
方法
getCanvas()
getCanvas():
HTMLCanvasElement
定义于: src/source/canvas_source.ts:145
返回HTML canvas
元素;
返回
HTMLCanvasElement
HTML canvas
元素;
listens()
listens(
type
:string
):boolean
定义于: src/util/evented.ts:165
如果这个Evented实例或任何被转发的Evented实例有指定类型的监听器,则返回true;
参数
参数 | 类型 | 描述 |
---|---|---|
type | string | 事件类型 |
返回
boolean
如果为指定的事件类型注册了至少一个监听器,则返回true
,否则返回false
;
继承自
ImageSource.listens
loaded()
loaded():
boolean
定义于: src/source/image_source.ts:163
如果源已加载,则为true,否则为false;
返回
boolean
继承自
ImageSource.loaded
loadTile()
loadTile(
tile
: Tile):Promise
<void
>
定义于: src/source/image_source.ts:275
此方法完成加载图块的繁重工作;在大多数情况下,它会将工作委托给相关的工作器源(worker source);
参数
参数 | 类型 | 描述 |
---|---|---|
tile | Tile | 要加载的图块 |
返回
Promise
<void
>
继承自
ImageSource.loadTile
off()
off(
type
:string
,listener
: Listener):CanvasSource
定义于: src/util/evented.ts:90
移除先前注册的事件监听器;
参数
参数 | 类型 | 描述 |
---|---|---|
type | string | 要移除监听器的事件类型 |
listener | Listener | 要移除的监听器函数 |
返回
CanvasSource
继承自
ImageSource.off
on()
on(
type
:string
,listener
: Listener): Subscription
定义于: src/util/evented.ts:73
为指定的事件类型添加监听器;
参数
参数 | 类型 | 描述 |
---|---|---|
type | string | 要添加监听的事件类型 |
listener | Listener | 事件触发时要调用的函数;监听器函数使用传递给fire的数据对象调用,该对象扩展了target和type属性 |
返回
Subscription
继承自
ImageSource.on
once()
once(
type
:string
,listener?
: Listener):Promise
<any
> |CanvasSource
定义于: src/util/evented.ts:106
添加一个只会被调用一次的监听器到指定的事件类型;
监听器将在注册后事件首次触发时被调用;
参数
参数 | 类型 | 描述 |
---|---|---|
type | string | 要监听的事件类型 |
listener? | Listener | 事件首次触发时要调用的函数 |
返回
Promise
<any
> | CanvasSource
如果没有提供监听器,则返回this
或一个promise
继承自
ImageSource.once
setCoordinates()
setCoordinates(
coordinates
: Coordinates):this
定义于: src/source/image_source.ts:215
设置图像的坐标并重新渲染地图;
参数
参数 | 类型 | 描述 |
---|---|---|
coordinates | Coordinates | 四个地理坐标,表示为经度和纬度数字的数组,定义图像的角;坐标从图像的左上角开始,按顺时针方向排列;它们不必表示一个矩形 |
返回
this
继承自
ImageSource.setCoordinates
setEventedParent()
setEventedParent(
parent?
: Evented,data?
:any
):CanvasSource
定义于: src/util/evented.ts:176
将此Evented实例触发的所有事件冒泡到此父Evented实例;
参数
参数 | 类型 | 描述 |
---|---|---|
parent? | Evented | |
data? | any |
返回
CanvasSource
继承自
ImageSource.setEventedParent
updateImage()
updateImage(
options
: UpdateImageOptions):this
定义于: src/source/image_source.ts:173
更新图像URL,并可选择更新坐标;为避免更改后图像闪烁,请将栅格图层上的raster-fade-duration
绘制属性设置为0;
参数
参数 | 类型 | 描述 |
---|---|---|
options | UpdateImageOptions | 选项对象 |
返回
this
继承自
ImageSource.updateImage
属性
id
id:
string
定义于: src/source/image_source.ts:94
源的ID;不能被任何现有源使用;
继承自
ImageSource.id
maxzoom
maxzoom:
number
定义于: src/source/image_source.ts:96
源的最大缩放级别;
继承自
ImageSource.maxzoom
minzoom
minzoom:
number
定义于: src/source/image_source.ts:95
源的最小缩放级别;
继承自
ImageSource.minzoom
pause()
pause: () =>
void
定义于: src/source/canvas_source.ts:79
禁用动画;地图将显示画布图像的静态副本;
返回
void
play()
play: () =>
void
定义于: src/source/canvas_source.ts:75
启用动画;每一帧都会将图像从画布复制到地图上;
返回
void
terrainTileRanges
terrainTileRanges:
object
定义于: src/source/image_source.ts:103
此对象用于存储与此图块重叠的地形图块范围;对于图像图块很重要,因为图像超出了单个图块边界;
索引签名
[zoom
: string
]: CanonicalTileRange
继承自
ImageSource.terrainTileRanges
tileSize
tileSize:
number
定义于: src/source/image_source.ts:97
源的图块大小;
继承自
ImageSource.tileSize