Skip to content

Commit acae6d1

Browse files
committed
docs: improve docs
1 parent 80eb158 commit acae6d1

16 files changed

Lines changed: 653 additions & 109 deletions

CONTRIBUTING.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
## Example app
1212
The recommended way to develop is building the example app. Example app links in `@rnmapbox/maps` from parent directory. JavaScript changes for example in `src/components/MapView.tsx`, will be applied automatically.
1313
Some notes about example app:
14-
- example app are both for demonstrating how to use differenc components, so examples should be simple (and not all of them should be typescript)
15-
- example app can contains screens designed from through testing of a component, but it should be separate for simple components demonstrating the use of components
14+
- example app are both for demonstrating how to use different components, so examples should be simple (and not all of them should be typescript)
15+
- example app can contain screens designed for thorough testing of a component, but it should be separate from simple examples demonstrating the use of components
1616

1717
### Example app configurations:
1818

@@ -74,7 +74,7 @@ The full documentation generation process looks like this:
7474
7575
The source is `style-spec/v8.json` and documentation at `src/*.ts`
7676
77-
This step runs by `yarn generate` and checked if up-todate by CI.
77+
This step runs by `yarn generate` and checked if up-to-date by CI.
7878
7979
2.) `docs/examples.json` generated by `jest __tests__/dumpExamplesJson.ts`.
8080
@@ -83,9 +83,9 @@ The full documentation generation process looks like this:
8383
npx jest __tests__/dumpExamplesJson.ts
8484
```
8585
86-
This step runs by `yarn generate` and checked if up-todate by CI.
86+
This step runs by `yarn generate` and checked if up-to-date by CI.
8787
88-
3.) `<doc-site>/screenhsots`. Grab screenshots from examples (needs `docs/examples.json`)
88+
3.) `<doc-site>/screenshots`. Grab screenshots from examples (needs `docs/examples.json`)
8989
9090
We use detox tests to capture screenshots of examples
9191
```
@@ -96,15 +96,15 @@ The full documentation generation process looks like this:
9696
9797
This step is run manually for now
9898
99-
4.) `<doc-site>/docs/components` Generate component/api documentation (into the docosaurus site)
99+
4.) `<doc-site>/docs/components` Generate component/api documentation (into the Docusaurus site)
100100
101101
```
102102
node scripts/doc-generate.mjs
103103
```
104104
105105
Runs when `main` is changed by `update-docs` gh action workflow
106106
107-
5.) `<doc-site>/docs/exmaples` Generate example docs (into the docosaurus site)
107+
5.) `<doc-site>/docs/examples` Generate example docs (into the Docusaurus site)
108108
109109
```
110110
bun scripts/example-docs.ts

docs/Camera.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ The easing or path the camera uses to animate to a new configuration.
125125
```tsx
126126
boolean
127127
```
128-
Whether the map orientation follows the user location.
128+
Whether the map camera follows the user's location. When enabled, the camera centers
129+
on the user's position and `centerCoordinate` is ignored.
130+
For more advanced location tracking, consider using {@link Viewport} with `followPuck` state instead.
129131
130132
131133
@@ -134,7 +136,10 @@ Whether the map orientation follows the user location.
134136
```tsx
135137
UserTrackingMode
136138
```
137-
The mode used to track the user location on the map.
139+
The mode used to track the user location on the map. Only takes effect when `followUserLocation` is true.
140+
- `normal`: the camera follows the user's position without rotating the map
141+
- `compass`: the camera rotates to match the device's compass heading (direction the device is facing)
142+
- `course`: the camera rotates to match the user's direction of travel
138143
139144
140145
@@ -143,7 +148,8 @@ The mode used to track the user location on the map.
143148
```tsx
144149
number
145150
```
146-
The zoom level used when following the user location.
151+
The zoom level used when following the user location. If not specified,
152+
the current zoom level is preserved.
147153
148154
[Show Map](../examples/Map/ShowMap)
149155
@@ -152,7 +158,8 @@ The zoom level used when following the user location.
152158
```tsx
153159
number
154160
```
155-
The pitch used when following the user location.
161+
The pitch (tilt) used when following the user location, in degrees. If not specified,
162+
the current pitch is preserved.
156163
157164
158165
@@ -161,7 +168,8 @@ The pitch used when following the user location.
161168
```tsx
162169
number
163170
```
164-
The heading used when following the user location.
171+
The heading (bearing) used when following the user location, in degrees. If not specified,
172+
the heading is determined by `followUserMode`.
165173
166174
167175
@@ -170,7 +178,8 @@ The heading used when following the user location.
170178
```tsx
171179
Partial
172180
```
173-
The padding used to position the user location when following.
181+
Padding in points that offsets the user's centered position from the edges of the map view.
182+
Useful for keeping the user location visible when UI elements overlap the map.
174183
175184
176185

docs/CustomLocationProvider.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@ import { CustomLocationProvider } from '@rnmapbox/maps';
88
CustomLocationProvider
99

1010
```
11+
Overrides the native location provider with custom coordinates and heading.
1112

13+
Useful for simulating locations during development, integrating an external
14+
positioning sensor, or writing tests. Must be a child of `MapView`.
15+
Use together with `LocationPuck` to display the custom position on the map.
16+
17+
@example
18+
&lt;MapView&gt;
19+
&lt;CustomLocationProvider coordinate={[-73.9857, 40.7484]} heading={90} />
20+
<LocationPuck puckBearingEnabled={true} puckBearing="heading" />
21+
</MapView>
1222

1323
## props
1424

@@ -18,7 +28,7 @@ CustomLocationProvider
1828
```tsx
1929
Position
2030
```
21-
longitude and latitude to use for the custom location provider that gets applied to the NativeUserLocation
31+
The position as a `[longitude, latitude]` pair, transmitted to the native puck as the current location.
2232

2333

2434

@@ -27,7 +37,8 @@ longitude and latitude to use for the custom location provider that gets applied
2737
```tsx
2838
number
2939
```
30-
heading/bearing to use for custom location provider that gets applied to the NativeUserLocation
40+
Heading in degrees (0 = north, 90 = east, 180 = south, 270 = west).
41+
Controls the rotation of the location puck when `puckBearingEnabled` is true on the `LocationPuck`.
3142

3243

3344

docs/LocationPuck.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import { LocationPuck } from '@rnmapbox/maps';
88
LocationPuck
99

1010
```
11-
Renders a puck on the map that shows the device's current location.
11+
Renders the native Mapbox location puck on the map to show the device's current location.
12+
13+
This is the recommended way to display user location, as it leverages the native
14+
Mapbox location indicator with smooth animations and built-in bearing tracking.
15+
Must be a child of `MapView`.
1216

1317
## props
1418

@@ -108,7 +112,7 @@ The size of the images, as a scale factor applied to the size of the specified i
108112
```tsx
109113
| {
110114
/**
111-
* Flag determining whether the pulsing circle animation.
115+
* Flag determining whether the pulsing circle animation is enabled.
112116
*/
113117
isEnabled?: boolean;
114118

@@ -119,14 +123,17 @@ The size of the images, as a scale factor applied to the size of the specified i
119123

120124
/**
121125
* Circle radius configuration for the pulsing circle animation.
122-
* - accuracy: Pulsing circle animates with the `horizontalAccuracy` form the latest puck location.
123-
* - number: Pulsing circle should animate with the constant radius.
126+
* - `'accuracy'`: Pulsing circle radius is based on the `horizontalAccuracy` from the latest
127+
* location, providing a visual representation of GPS precision.
128+
* - `number`: Pulsing circle uses a constant radius in screen points.
124129
*/
125130
radius?: 'accuracy' | number;
126131
}
127132
| 'default'
128133
```
129-
The configration parameters for sonar-like pulsing circle animation shown around the 2D puck.
134+
The configuration parameters for sonar-like pulsing circle animation shown around the 2D puck.
135+
Set to `'default'` to enable pulsing with platform default settings. Pass an object to customize.
136+
Omit or set to `undefined` to disable pulsing.
130137

131138

132139

docs/UserLocation.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ import { UserLocation } from '@rnmapbox/maps';
88
UserLocation
99

1010
```
11+
Displays the user's current location on the map with a customizable appearance.
1112

13+
By default, renders a blue circle indicator. Provide children (layer components) to
14+
customize the appearance. Uses `locationManager` internally to subscribe to location
15+
updates, with automatic start/stop on mount/unmount and background/foreground transitions.
16+
17+
For a simpler native-rendered location indicator, consider using {@link LocationPuck} directly.
1218

1319
## props
1420

@@ -52,7 +58,8 @@ Custom location icon of type mapbox-gl-native components
5258
```tsx
5359
number
5460
```
55-
Minimum amount of movement before GPS location is updated in meters
61+
Minimum distance in meters the device must move before a location update is generated.
62+
Maps to `distanceFilter` on iOS and `displacement` on Android. Defaults to 0.
5663

5764
_defaults to:_ `0`
5865
[Set Displacement](../examples/UserLocation/SetDisplacement)
@@ -72,7 +79,9 @@ Callback that is triggered on location icon press
7279
```tsx
7380
func
7481
```
75-
Callback that is triggered on location update
82+
Callback that is triggered on each location update. Receives a {@link Location} object
83+
containing `coords` (latitude, longitude, altitude, accuracy, heading, course, speed)
84+
and `timestamp`.
7685
*signature:*`(location:Location) =&gt; void`
7786

7887
[User Location Updates](../examples/UserLocation/UserLocationUpdates)
@@ -93,7 +102,10 @@ Which render mode to use.
93102
```tsx
94103
boolean
95104
```
96-
Request the always location permission, and listen to the location even when the app is in background
105+
Request the always location permission, and listen to the location even when the app is in background.
106+
107+
**Note:** This is not implemented in Mapbox Maps SDK v11 and is currently a no-op
108+
on both iOS and Android.
97109

98110
@platform ios
99111

docs/Viewport.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,20 @@ import { Viewport } from '@rnmapbox/maps';
88
Viewport
99

1010
```
11-
provides a structured approach to organizing camera management logic into states and transitions between them.
11+
Provides a structured approach to organizing camera management logic into states and transitions between them.
12+
13+
Viewport is the modern alternative to Camera's `followUserLocation` for tracking the user's position.
14+
It supports two built-in states:
15+
- `followPuck`: tracks the user's location with configurable zoom, pitch, and bearing
16+
- `overview`: frames a given geometry with configurable padding, bearing, and pitch
1217

1318
At any given time, the viewport is either:
14-
- idle
15-
- in a state (camera is being managed by a ViewportState)
19+
- idle (not managing the camera)
20+
- in a state (camera is actively managed by a ViewportState)
1621
- transitioning between states
1722

18-
See [android](https://docs.mapbox.com/android/maps/api/${ANDROID_SDK_VERSION}/mapbox-maps-android/com.mapbox.maps.plugin.viewport/viewport.html),
19-
[ios](https://docs.mapbox.com/ios/maps/api/${IOS_SDK_VERSION}/Viewport.html#/s:10MapboxMaps8ViewportC)
23+
See [Android Viewport](https://docs.mapbox.com/android/maps/api/11.0.0/mapbox-maps-android/com.mapbox.maps.plugin.viewport/viewport.html),
24+
[iOS Viewport](https://docs.mapbox.com/ios/maps/api/11.0.0/Viewport.html)
2025

2126
## props
2227

@@ -57,7 +62,7 @@ delivery of status changed notifications.
5762
## methods
5863
### getState()
5964

60-
65+
Returns the current state of the viewport as a JSON string.
6166

6267
#### arguments
6368
| Name | Type | Required | Description |
@@ -67,7 +72,7 @@ delivery of status changed notifications.
6772

6873
### idle()
6974

70-
75+
Sets the viewport to idle, stopping any active state or transition.
7176

7277
#### arguments
7378
| Name | Type | Required | Description |
@@ -77,13 +82,13 @@ delivery of status changed notifications.
7782

7883
### transitionTo(state, transition)
7984

80-
85+
Transitions the viewport to a new state with an optional transition animation.
8186

8287
#### arguments
8388
| Name | Type | Required | Description |
8489
| ---- | :--: | :------: | :----------: |
85-
| `state` | `n/a` | `Yes` | undefined |
86-
| `transition` | `n/a` | `Yes` | undefined |
90+
| `state` | `ViewportState` | `Yes` | The target state (followPuck or overview). |
91+
| `transition` | `ViewportTransition` | `Yes` | The transition to use (immediate or default). |
8792

8893

8994

docs/coordinates.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import { coordinates } from '@rnmapbox/maps';
88
coordinates
99

1010
```
11-
Coorinates sent by locationManager
11+
Geographic coordinates sent by locationManager.Fields:Note: heading (compass direction the device is facing) and course (direction of travel) are distinct values.
12+
On Android, both currently return the same value (see related issues above).
1213

1314

1415

0 commit comments

Comments
 (0)