VideoSource Class

Extends: Evented
Module: Source

添加一个视频源

// add to map

map.addSource('some id', {
   type: 'video',
   url: [
       'http://minedata.com.cn/minemapapi/demo/assets/drone.mp4',
   ],
   coordinates: [
       [116.38, 39.009],
       [116.39, 39.009],
       [116.39, 39.008],
       [116.38, 39.008]
   ]
});

// update

var mySource = map.getSource('some id');
mySource.setCoordinates([
    [116.38, 39.009],
    [116.39, 39.009],
    [116.39, 39.008],
    [116.38, 39.008]
]);

// remove

map.removeSource('some id');
Show:

Methods

loadTile

(tilecallback)

Parameters:

  • tile Tile
  • callback Funtion

    Called when tile has been loaded

abortTile

(tile)

Parameters:

  • tile Tile

unloadTile

(tile)

Parameters:

  • tile Tile

serialize

()

Returns:

Object

A plain (stringifiable) JS object representing the current state of the source. Creating a source using the returned object as the options should result in a Source that is equivalent to this one.

prepare

()

loadTile

(paramscallback)

Loads a tile from the given params and parse it into buckets ready to send back to the main thread for rendering. Should call the callback with: { buckets, featureIndex, collisionTile, symbolInstancesArray, symbolQuadsArray, rawTileData}.

Parameters:

  • params Object

    Parameters sent by the main-thread Source identifying the tile to load.

  • callback Function

reloadTile

(paramscallback)

Re-parses a tile that has already been loaded. Yields the same data as 参见Map/loadTile:method

Parameters:

  • params Object
  • callback Function

abortTile

(params)

Aborts loading a tile that is in progress.

Parameters:

  • params Object

removeTile

()

Removes this tile from any local caches.

loadTile

(params)

Implements WorkerSource#loadTile:method.Delegates to VectorTileWorkerSource#loadVectorData:method (which by default expects a params.url property) for fetching and producing a VectorTile object.

Parameters:

  • params Object

reloadTile

(params)

Implements {@link WorkerSource#reloadTile}.

Parameters:

  • params Object

abortTile

(params)

Implements {@link WorkerSource#abortTile}.

Parameters:

  • params Object

removeTile

(params)

Implements {@link WorkerSource#removeTile}.

Parameters:

  • params Object

loadVectorData

(params)

Parameters:

  • params Object

getVideo

()

返回HTMLvideo元素.

Returns:

HTMLVideoElement

The HTML video element.

setCoordinates

(coordinates)

设置视频在地图上渲染的坐标。

Parameters:

  • coordinates Array(Array(number))

    一个包含四个坐标点的经纬度数组,从video左上角开始。此区域不需要为长方形。

Returns:

on

(typelistener)
Inherited from Evented:

添加一个具体的事件监听

Parameters:

  • type String
    事件类型
  • listener Function
    监听器

Returns:

Object
this

off

(typelistener)
Inherited from Evented:

注销一个事件监听

Parameters:

  • type String (optional)
    事件类型
  • listener Function (optional)
    监听器,如果忽略此项,所有此类型的事件将会全部删除。

Returns:

Object
this

once

(typelistener)
Inherited from Evented:

添加一个只执行一次的事件。

Parameters:

  • type String
    事件类型
  • listener Function
    事件监听器

Returns:

Object
this

fire

(typedata)
Inherited from Evented:

触发一个类型的事件

Parameters:

  • type String
    事件类型
  • data Object (optional)
    传输到其它监听器里面的数据

Returns:

Object
this

listens

(type)
Inherited from Evented:

返回一个布尔值标识是否有其它的监听器监听该事件。

Parameters:

  • type String
    时间类型

Returns:

Boolean
true 是否有监听器的标识位。

Properties

Events