# ImageSource

扩展事件

包含图像的数据源。(见样式规范 有关选项的详细文档。)

# Parameters

  • id string
  • options (ImageSourceSpecification | VideoSourceSpecification | CanvasSourceSpecification)
  • dispatcher 调度员
  • eventedParent 事件发生

# Examples

// add to map
map.addSource('some id', {
   type: 'image',
   url: 'https://xxx.png',
   coordinates: [
       [-76.54, 39.18],
       [-76.52, 39.18],
       [-76.52, 39.17],
       [-76.54, 39.17]
   ]
});

// update coordinates
var mySource = map.getSource('some id');
mySource.setCoordinates([
    [-76.54335737228394, 39.18579907229748],
    [-76.52803659439087, 39.1838364847587],
    [-76.5295386314392, 39.17683392507606],
    [-76.54520273208618, 39.17876344106642]
]);

// update url and coordinates simultaneously
mySource.updateImage({
   url: 'https://xxx.png',
   coordinates: [
       [-76.54335737228394, 39.18579907229748],
       [-76.52803659439087, 39.1838364847587],
       [-76.5295386314392, 39.17683392507606],
       [-76.54520273208618, 39.17876344106642]
   ]
})

map.removeSource('some id');  // remove
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

# updateImage

更新图像 URL 和(可选)坐标。为避免更改后图像闪烁,请将raster-fade-duration光栅图层上的paint属性设置为0。

# Parameters

  • options Object 选项对象。
    • options.url string? 必需的图像 URL。
    • options.coordinates **Array< Array< number>>?**四个地理坐标,表示为经度和纬度数字数组,用于定义图像的角点。坐标从图像的左上角开始,并按顺时针顺序进行。它们不必表示一个矩形。

返回**[ImageSource][268]**这个

# setCoordinates

设置图像的坐标并重新渲染地图。

# Parameters

  • coordinates **Array< Array< number>>**四地理坐标,表示为经度和纬度的数字阵列,它定义了图像的角上。坐标从图像的左上角开始,并按顺时针顺序进行。它们不必表示一个矩形。

返回**[ImageSource][268]**这个