<MapboxGL.Camera />
props 属性
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
| animationDuration 动画持续时间 |
number |
2000 |
false |
FIX ME NO DESCRIPTION |
| animationMode 动画模式 |
enum |
'easeTo' |
false |
FIX ME NO DESCRIPTION |
| defaultSettings 默认设置 |
shape |
none |
false |
FIX ME NO DESCRIPTION |
| -> centerCoordinate 中心坐标 |
array |
none |
false |
Center coordinate on map [lng, lat] |
| -> heading | number |
none |
false |
Heading on map |
| -> pitch | number |
none |
false |
Pitch on map |
| -> bounds | shape |
none |
false |
FIX ME NO DESCRIPTION |
| -> ne | array |
none |
true |
northEastCoordinates - North east coordinate of bound |
| -> sw | array |
none |
true |
southWestCoordinates - North east coordinate of bound |
| -> paddingLeft | number |
none |
false |
Left camera padding for bounds |
| -> paddingRight | number |
none |
false |
Right camera padding for bounds |
| -> paddingTop | number |
none |
false |
Top camera padding for bounds |
| -> paddingBottom | number |
none |
false |
Bottom camera padding for bounds |
| -> zoomLevel | number |
none |
false |
Zoom level of the map |
| centerCoordinate | array |
none |
false |
Center coordinate on map [lng, lat] |
| heading | number |
none |
false |
Heading on map |
| pitch | number |
none |
false |
Pitch on map |
| bounds | shape |
none |
false |
FIX ME NO DESCRIPTION |
| ne | array |
none |
true |
northEastCoordinates - North east coordinate of bound |
| sw | array |
none |
true |
southWestCoordinates - North east coordinate of bound |
| paddingLeft | number |
none |
false |
Left camera padding for bounds |
| paddingRight | number |
none |
false |
Right camera padding for bounds |
| paddingTop | number |
none |
false |
Top camera padding for bounds |
| paddingBottom | number |
none |
false |
Bottom camera padding for bounds |
| zoomLevel | number |
none |
false |
Zoom level of the map |
| minZoomLevel | number |
none |
false |
FIX ME NO DESCRIPTION |
| maxZoomLevel | number |
none |
false |
FIX ME NO DESCRIPTION |
| maxBounds | shape |
none |
false |
Restrict map panning so that the center is within these bounds |
| ne | array |
none |
true |
northEastCoordinates - North east coordinate of bound |
| sw | array |
none |
true |
southWestCoordinates - South west coordinate of bound |
| followUserLocation 跟随用户位置 |
bool |
none |
false |
FIX ME NO DESCRIPTION |
| followUserMode | enum |
none |
false |
FIX ME NO DESCRIPTION |
| followZoomLevel |
number |
none |
false |
FIX ME NO DESCRIPTION |
| followPitch |
number |
none |
false |
FIX ME NO DESCRIPTION |
| followHeading |
number |
none |
false |
FIX ME NO DESCRIPTION |
| triggerKey 触发键 |
any |
none |
false |
FIX ME NO DESCRIPTION |
| alignment |
array |
none |
false |
FIX ME NO DESCRIPTION |
| onUserTrackingModeChange 用户跟踪模式更改事件 |
func |
none |
false |
FIX ME NO DESCRIPTION |
| isUserInteraction | FIX ME UNKNOWN TYPE |
false |
false |
FIX ME NO DESCRIPTION |
methods 方法
fitBounds(northEastCoordinates, southWestCoordinates[, padding][, animationDuration])
Map camera transitions to fit provided bounds
地图视图适应提供的边界
arguments
| Name | Type | Required | Description |
|---|---|---|---|
northEastCoordinates |
Array |
Yes |
North east coordinate of bound |
southWestCoordinates |
Array |
Yes |
South west coordinate of bound |
padding |
Number |
No |
Camera padding for bound |
animationDuration |
Number |
No |
Duration of camera animation |
this.camera.fitBounds([lng, lat], [lng, lat])
this.camera.fitBounds([lng, lat], [lng, lat], 20, 1000) // padding for all sides
this.camera.fitBounds([lng, lat], [lng, lat], [verticalPadding, horizontalPadding], 1000)
this.camera.fitBounds([lng, lat], [lng, lat], [top, right, bottom, left], 1000)
flyTo(coordinates[, animationDuration])
Map camera will fly to new coordinate
地图相机将飞到新坐标
arguments
| Name | Type | Required | Description |
|---|---|---|---|
coordinates |
Array |
Yes |
Coordinates that map camera will jump too |
animationDuration |
Number |
No |
Duration of camera animation |
this.camera.flyTo([lng, lat])
this.camera.flyTo([lng, lat], 12000)
moveTo(coordinates[, animationDuration])
Map camera will move to new coordinate at the same zoom level
地图相机将移动到相同缩放级别的新坐标
arguments
| Name | Type | Required | Description |
|---|---|---|---|
coordinates |
Array |
Yes |
Coordinates that map camera will move too |
animationDuration |
Number |
No |
Duration of camera animation |
this.camera.moveTo([lng, lat], 200) // eases camera to new location based on duration
this.camera.moveTo([lng, lat]) // snaps camera to new location without any easing
zoomTo(zoomLevel[, animationDuration])
Map camera will zoom to specified level
地图相机将缩放到指定级别
arguments
| Name | Type | Required | Description |
|---|---|---|---|
zoomLevel |
Number |
Yes |
Zoom level that the map camera will animate too |
animationDuration |
Number |
No |
Duration of camera animation |
this.camera.zoomTo(16)
this.camera.zoomTo(16, 100)
setCamera(config)
Map camera will perform updates based on provided config. Advanced use only!
地图摄像机将根据提供的配置执行更新。仅限高级使用!
arguments
| Name | Type | Required | Description |
|---|---|---|---|
config |
Object |
Yes |
Camera configuration |
this.camera.setCamera({
centerCoordinate: [lng, lat],
zoomLevel: 16,
animationDuration: 2000,
})
this.camera.setCamera({
stops: [
{ pitch: 45, animationDuration: 200 },
{ heading: 180, animationDuration: 300 },
]
})