Files

161 lines
7.3 KiB
Markdown
Raw Permalink Normal View History

2017-08-24 11:05:43 -07:00
## <MapboxGL.MapView />
### MapView backed by Mapbox Native GL
2017-09-07 17:02:32 -07:00
### props
2017-08-24 11:05:43 -07:00
| Prop | Type | Default | Required | Description |
2017-09-07 17:02:32 -07:00
| ---- | :--: | :-----: | :------: | :----------: |
2017-09-01 09:59:10 -07:00
| animated | `bool` | `false` | `false` | Animates changes between pitch and bearing |
| centerCoordinate | `arrayOf` | `none` | `false` | Initial center coordinate on map [lng, lat] |
| showUserLocation | `bool` | `none` | `false` | Shows the users location on the map |
| userTrackingMode | `number` | `MapboxGL.UserTrackingModes.None` | `false` | The mode used to track the user location on the map |
2017-08-24 11:05:43 -07:00
| heading | `number` | `0` | `false` | Initial heading on map |
| pitch | `number` | `0` | `false` | Initial pitch on map |
| style | `any` | `none` | `false` | Style for wrapping React Native View |
2017-09-01 09:59:10 -07:00
| styleURL | `string` | `MapboxGL.StyleURL.Street` | `false` | Style URL for map |
2017-08-24 11:05:43 -07:00
| zoomLevel | `number` | `16` | `false` | Initial zoom level of map |
| minZoomLevel | `number` | `none` | `false` | Min zoom level of map |
| maxZoomLevel | `number` | `none` | `false` | Max zoom level of map |
2017-09-01 09:59:10 -07:00
| scrollEnabled | `bool` | `true` | `false` | Enable/Disable scroll on the map |
| pitchEnabled | `bool` | `true` | `false` | Enable/Disable pitch on map |
| rotateEnabled | `bool` | `true` | `false` | Enable/Disable rotation on map |
| attributionEnabled | `bool` | `true` | `false` | Enable/Disable attribution on map. For iOS you need to add MGLMapboxMetricsEnabledSettingShownInApp=YES<br/>to your Info.plist |
| logoEnabled | `bool` | `true` | `false` | Enable/Disable the logo on the map. |
2017-08-24 16:42:17 -07:00
| onPress | `func` | `none` | `false` | Map press listener, gets called when a user presses the map |
| onLongPress | `func` | `none` | `false` | Map long press listener, gets called when a user long presses the map |
2017-09-01 09:59:10 -07:00
| onRegionWillChange | `func` | `none` | `false` | This event is triggered whenever the currently displayed map region is about to change. |
| onRegionIsChanging | `func` | `none` | `false` | This event is triggered whenever the currently displayed map region is changing. |
| onRegionDidChange | `func` | `none` | `false` | This event is triggered whenever the currently displayed map region finished changing |
| onWillStartLoadingMap | `func` | `none` | `false` | This event is triggered when the map is about to start loading a new map style. |
| onDidFinishLoadingMap | `func` | `none` | `false` | This is triggered when the map has successfully loaded a new map style. |
| onDidFailLoadingMap | `func` | `none` | `false` | This event is triggered when the map has failed to load a new map style. |
| onWillStartRenderingFrame | `func` | `none` | `false` | This event is triggered when the map will start rendering a frame. |
| onDidFinishRenderingFrame | `func` | `none` | `false` | This event is triggered when the map finished rendering a frame. |
| onDidFinishRenderingFrameFully | `func` | `none` | `false` | This event is triggered when the map fully finished rendering a frame. |
| onWillStartRenderingMap | `func` | `none` | `false` | This event is triggered when the map will start rendering the map. |
| onDidFinishRenderingMap | `func` | `none` | `false` | This event is triggered when the map finished rendering the map. |
| onDidFinishRenderingMapFully | `func` | `none` | `false` | This event is triggered when the map fully finished rendering the map. |
| onDidFinishLoadingStyle | `func` | `none` | `false` | This event is triggered when a style has finished loading. |
| onFlyToComplete | `func` | `none` | `false` | This event is triggered when a fly to animation is cancelled or completed after calling flyTo |
| onSetCameraComplete | `func` | `none` | `false` | This event is triggered once the camera is finished after calling setCamera |
2017-08-24 11:05:43 -07:00
2017-09-07 17:02:32 -07:00
### methods
#### queryRenderedFeaturesAtPoint(coordinate[, filter][, layerIDs])
##### arguments
| Name | Type | Required | Description |
| ---- | :--: | :------: | :----------: |
| `coordinate` | `Array` | `Yes` | A point expressed in the map views coordinate system. |
| `filter` | `Array` | `No` | A set of strings that correspond to the names of layers defined in the current style. Only the features contained in these layers are included in the returned array. |
| `layerIDs` | `Array` | `No` | A array of layer id's to filter the features by |
```javascript
this._map.queryRenderedFeaturesAtPoint([30, 40], ['==', 'type', 'Point'], ['id1', 'id2'])
```
#### queryRenderedFeaturesInRect(bbox[, filter][, layerIDs])
##### arguments
| Name | Type | Required | Description |
| ---- | :--: | :------: | :----------: |
| `bbox` | `Array` | `Yes` | A rectangle expressed in the map views coordinate system. |
| `filter` | `Array` | `No` | A set of strings that correspond to the names of layers defined in the current style. Only the features contained in these layers are included in the returned array. |
| `layerIDs` | `Array` | `No` | A array of layer id's to filter the features by |
```javascript
this._map.queryRenderedFeaturesInRect([30, 40, 20, 10], ['==', 'type', 'Point'], ['id1', 'id2'])
```
2017-09-07 17:02:32 -07:00
#### fitBounds(northEastCoordinates, southWestCoordinates[, padding][, duration])
##### 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 |
| `duration` | `Number` | `No` | Duration of camera animation |
```javascript
this.map.fitBounds([lng, lat], [lng, lat])
this.map.fitBounds([lng, lat], [lng, lat], 20, 1000) // padding for all sides
this.map.fitBounds([lng, lat], [lng, lat], [verticalPadding, horizontalPadding], 1000)
this.map.fitBounds([lng, lat], [lng, lat], [top, right, bottom, left], 1000)
2017-09-07 17:02:32 -07:00
```
#### flyTo(coordinates[, duration])
##### arguments
| Name | Type | Required | Description |
| ---- | :--: | :------: | :----------: |
| `coordinates` | `Array` | `Yes` | Coordinates that map camera will jump too |
| `duration` | `Number` | `No` | Duration of camera animation |
```javascript
this.map.flyTo([lng, lat])
this.map.flyTo([lng, lat], 12000)
```
2017-10-23 16:21:54 -07:00
#### moveTo(coordinates[, duration])
##### arguments
| Name | Type | Required | Description |
| ---- | :--: | :------: | :----------: |
| `coordinates` | `Array` | `Yes` | Coordinates that map camera will move too |
| `duration` | `Number` | `No` | Duration of camera animation |
```javascript
this.map.moveTo([lng, lat], 200) // eases camera to new location based on duration
this.map.moveTo([lng, lat]) // snaps camera to new location without any easing
```
2017-09-07 17:02:32 -07:00
#### zoomTo(zoomLevel[, duration])
##### arguments
| Name | Type | Required | Description |
| ---- | :--: | :------: | :----------: |
| `zoomLevel` | `Number` | `Yes` | Zoom level that the map camera will animate too |
| `duration` | `Number` | `No` | Duration of camera animation |
```javascript
this.map.zoomTo(16)
this.map.zoomTo(16, 100)
```
#### setCamera(config)
##### arguments
| Name | Type | Required | Description |
| ---- | :--: | :------: | :----------: |
| `config` | `Object` | `Yes` | Camera configuration |
```javascript
this.map.setCamera({
centerCoordinate: [lng, lat],
zoomLevel: 16,
duration: 2000,
})
this.map.setCamera({
stops: [
{ pitch: 45, duration: 200 },
{ heading: 180, duration: 300 },
]
})
```
2017-09-22 14:45:19 -07:00