Skip to content

Commit db68a06

Browse files
committed
fix: improve docs
1 parent 24b7dd7 commit db68a06

File tree

5 files changed

+136
-113
lines changed

5 files changed

+136
-113
lines changed

docs/Camera.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ compatibility; the root `padding` prop should be used instead.
6262
```tsx
6363
number
6464
```
65-
The heading (orientation) of the map.
65+
Heading (bearing, orientation) of the map, measured in degrees clockwise from true north.
6666

6767

6868

@@ -71,7 +71,7 @@ The heading (orientation) of the map.
7171
```tsx
7272
number
7373
```
74-
The pitch of the map.
74+
The pitch toward the horizon measured in degrees, with 0 degrees resulting in a top-down view for a two-dimensional map.
7575

7676

7777

@@ -212,8 +212,8 @@ type DefaultSettings = {
212212
centerCoordinate: Position; /* The location on which the map should center. */
213213
bounds: intersection; /* The corners of a box around which the map should bound. Contains padding props for backwards
214214
compatibility; the root `padding` prop should be used instead. */
215-
heading: number; /* The heading (orientation) of the map. */
216-
pitch: number; /* The pitch of the map. */
215+
heading: number; /* Heading (bearing, orientation) of the map, measured in degrees clockwise from true north. */
216+
pitch: number; /* The pitch toward the horizon measured in degrees, with 0 degrees resulting in a top-down view for a two-dimensional map. */
217217
zoomLevel: number; /* The zoom level of the map. */
218218
padding: signature; /* The viewport padding in points. */
219219
animationDuration: number; /* The duration the map takes to animate to a new configuration. */

docs/MapView.md

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ Gesture configuration allows to control the user touch interaction.
317317
```tsx
318318
func
319319
```
320-
Map press listener, gets called when a user presses the map
320+
Map press listener, called when a user presses the map.
321321
*signature:*`(feature:GeoJSON.Feature) => void`
322322
323323
[Screen Coordinates](../examples/Map/ScreenCoordinates), [Show Click](../examples/Map/ShowClick)
@@ -327,7 +327,7 @@ Map press listener, gets called when a user presses the map
327327
```tsx
328328
func
329329
```
330-
Map long press listener, gets called when a user long presses the map
330+
Map long press listener, called when a user long presses the map.
331331
*signature:*`(feature:GeoJSON.Feature) => void`
332332

333333
[Screen Coordinates](../examples/Map/ScreenCoordinates)
@@ -549,39 +549,42 @@ the onPress event for the taps that deselect the annotation. Default is false.
549549
## methods
550550
### getPointInView(coordinate)
551551

552-
Converts a geographic coordinate to a point in the given view’s coordinate system.
552+
Converts a geographic coordinate to a screen coordinate relative to the map view.
553553

554554
#### arguments
555555
| Name | Type | Required | Description |
556556
| ---- | :--: | :------: | :----------: |
557-
| `coordinate` | `Position` | `Yes` | A point expressed in the map view's coordinate system. |
557+
| `coordinate` | `Position` | `Yes` | A point expressed in the map view's coordinate system `[longitude, latitude]`. |
558558

559559

560560

561561
```javascript
562-
const pointInView = await this._map.getPointInView([-37.817070, 144.949901]);
562+
const longitude = 144.949901;
563+
const latitude = -37.817070;
564+
const [x, y] = await this._map.getPointInView([longitude, latitude]);
563565
```
564566

565567

566568
[Screen Coordinates](../examples/Map/ScreenCoordinates)### getCoordinateFromView(point)
567569

568-
Converts a point in the given view’s coordinate system to a geographic coordinate.
570+
Converts a screen coordinate relative to the map view to a geographic coordinate.
569571

570572
#### arguments
571573
| Name | Type | Required | Description |
572574
| ---- | :--: | :------: | :----------: |
573-
| `point` | `Position` | `Yes` | A point expressed in the given view’s coordinate system. |
575+
| `point` | `Position` | `Yes` | A point expressed in screen coordinates relative to the map view `[x, y]`. |
574576

575577

576578

577579
```javascript
578-
const coordinate = await this._map.getCoordinateFromView([100, 100]);
580+
const x = 100; const y = 100;
581+
const [longitude, latitude] = await this._map.getCoordinateFromView([x, y]);
579582
```
580583

581584

582585
[Screen Coordinates](../examples/Map/ScreenCoordinates)### getVisibleBounds()
583586

584-
The coordinate bounds (ne, sw) visible in the user’s viewport.
587+
The coordinate bounds of the map viewport.
585588

586589
#### arguments
587590
| Name | Type | Required | Description |
@@ -591,7 +594,7 @@ The coordinate bounds (ne, sw) visible in the user’s viewport.
591594

592595

593596
```javascript
594-
const visibleBounds = await this._map.getVisibleBounds();
597+
const [[rightLon, topLat], [leftLon, bottomLat]] = await this._map.getVisibleBounds();
595598
```
596599

597600

@@ -602,14 +605,15 @@ Returns an array of rendered map features that intersect with a given point.
602605
#### arguments
603606
| Name | Type | Required | Description |
604607
| ---- | :--: | :------: | :----------: |
605-
| `coordinate` | `Position` | `Yes` | A point expressed in the map view’s coordinate system. |
606-
| `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. |
607-
| `layerIDs` | `Array` | `No` | A array of layer id's to filter the features by |
608+
| `coordinate` | `Position` | `Yes` | A point expressed in the map view’s coordinate system `[x, y]`; |
609+
| `filter` | `FilterExpression \| tuple` | `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. |
610+
| `layerIDs` | `Array` | `No` | A array of layer IDs by which to filter the features. |
608611

609612

610613

611614
```javascript
612-
this._map.queryRenderedFeaturesAtPoint([30, 40], ['==', 'type', 'Point'], ['id1', 'id2'])
615+
const x = 30; const y = 40;
616+
this._map.queryRenderedFeaturesAtPoint([x, y], ['==', 'type', 'Point'], ['id1', 'id2'])
613617
```
614618

615619

@@ -620,14 +624,16 @@ Returns an array of rendered map features that intersect with the given rectangl
620624
#### arguments
621625
| Name | Type | Required | Description |
622626
| ---- | :--: | :------: | :----------: |
623-
| `bbox` | `BBox \| []` | `Yes` | A rectangle expressed in the map view’s coordinate system, density independent pixels and not map coordinates. This can be an empty array to query the visible map area. |
624-
| `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. |
625-
| `layerIDs` | `Array` | `No` | A array of layer id's to filter the features by |
627+
| `bbox` | `BBox \| []` | `Yes` | A rectangle expressed in density-independent screen coordinates relative to the map view `[top, left, bottom, right]` or `[minY, minX, maxY, maxX]` (not geographic coordinates). An empty array queries the visible map area. |
628+
| `filter` | `FilterExpression` | `No` | An array 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. |
629+
| `layerIDs` | `Array` | `No` | A array of layer IDs by which to filter the features. |
626630

627631

628632

629633
```javascript
630-
this._map.queryRenderedFeaturesInRect([30, 40, 20, 10], ['==', 'type', 'Point'], ['id1', 'id2'])
634+
const left = 40; const top = 30;
635+
const right = 10; const bottom = 20;
636+
this._map.queryRenderedFeaturesInRect([top, left, bottom, right], ['==', 'type', 'Point'], ['id1', 'id2'])
631637
```
632638

633639

@@ -639,7 +645,7 @@ Returns an array of GeoJSON Feature objects representing features within the spe
639645
| Name | Type | Required | Description |
640646
| ---- | :--: | :------: | :----------: |
641647
| `sourceId` | `string` | `Yes` | Style source identifier used to query for source features. |
642-
| `filter` | `Array` | `No` | A filter to limit query results. |
648+
| `filter` | `FilterExpression \| tuple` | `No` | A filter to limit query results. |
643649
| `sourceLayerIDs` | `Array` | `No` | The name of the source layers to query. For vector tile sources, this parameter is required. For GeoJSON sources, it is ignored. |
644650

645651

@@ -661,12 +667,12 @@ Map camera will perform updates based on provided config. Deprecated use Camera#
661667

662668
### takeSnap([writeToDisk])
663669

664-
Takes snapshot of map with current tiles and returns a URI to the image
670+
Takes snapshot of map with current tiles and returns a Base64-encoded PNG image,<br/>or an file-system URI to a temporary PNG file if `writeToDisk` is `true`.
665671

666672
#### arguments
667673
| Name | Type | Required | Description |
668674
| ---- | :--: | :------: | :----------: |
669-
| `writeToDisk` | `Boolean` | `No` | If true will create a temp file, otherwise it is in base64 |
675+
| `writeToDisk` | `boolean` | `No` | If `true`, creates a temporary PNG file and returns a file-system URI, otherwise returns a Base64-encoded PNG image. (Defaults to `false`) |
670676

671677

672678
### getZoom()
@@ -687,7 +693,7 @@ const zoom = await this._map.getZoom();
687693

688694
### getCenter()
689695

690-
Returns the map's geographical centerpoint
696+
Returns the map's center point expressed as geographic coordinates `[longitude, latitude]`.
691697

692698
#### arguments
693699
| Name | Type | Required | Description |
@@ -718,7 +724,7 @@ Queries the currently loaded data for elevation at a geographical location.<br/>
718724
#### arguments
719725
| Name | Type | Required | Description |
720726
| ---- | :--: | :------: | :----------: |
721-
| `coordinate` | `Position` | `Yes` | the coordinates to query elevation at |
727+
| `coordinate` | `Position` | `Yes` | The geographic coordinates `[longitude, latitude]` at which to query elevation. |
722728

723729

724730
[Query Terrain Elevation](../examples/V10/QueryTerrainElevation)### setSourceVisibility(visible, sourceId[, sourceLayerId])
@@ -729,8 +735,8 @@ Sets the visibility of all the layers referencing the specified `sourceLayerId`
729735
| Name | Type | Required | Description |
730736
| ---- | :--: | :------: | :----------: |
731737
| `visible` | `boolean` | `Yes` | Visibility of the layers |
732-
| `sourceId` | `string` | `Yes` | Identifier of the target source (e.g. 'composite') |
733-
| `sourceLayerId` | `String` | `No` | Identifier of the target source-layer (e.g. 'building') |
738+
| `sourceId` | `string` | `Yes` | Target source identifier (e.g. 'composite') |
739+
| `sourceLayerId` | `string` | `No` | Target source-layer identifier (e.g. 'building'). If `null`, the change affects all layers in the target source. |
734740

735741

736742

0 commit comments

Comments
 (0)