@rnmapbox/maps 10.0.0-beta.39 → 10.0.0-beta.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/docs/Annotation.md +1 -1
  2. package/docs/Atmosphere.md +1 -1
  3. package/docs/BackgroundLayer.md +1 -1
  4. package/docs/Callout.md +1 -1
  5. package/docs/Camera.md +1 -1
  6. package/docs/CircleLayer.md +1 -1
  7. package/docs/FillExtrusionLayer.md +1 -1
  8. package/docs/FillLayer.md +1 -1
  9. package/docs/HeadingIndicator.md +1 -1
  10. package/docs/HeatmapLayer.md +1 -1
  11. package/docs/ImageSource.md +1 -1
  12. package/docs/Images.md +1 -1
  13. package/docs/Light.md +1 -1
  14. package/docs/LineLayer.md +1 -1
  15. package/docs/MapView.md +1 -1
  16. package/docs/MarkerView.md +1 -1
  17. package/docs/NativeUserLocation.md +1 -1
  18. package/docs/PointAnnotation.md +12 -10
  19. package/docs/RasterDemSource.md +1 -1
  20. package/docs/RasterLayer.md +1 -1
  21. package/docs/RasterSource.md +1 -1
  22. package/docs/ShapeSource.md +1 -1
  23. package/docs/SkyLayer.md +1 -1
  24. package/docs/Style.md +1 -1
  25. package/docs/SymbolLayer.md +1 -1
  26. package/docs/Terrain.md +1 -1
  27. package/docs/UserLocation.md +1 -1
  28. package/docs/VectorSource.md +1 -1
  29. package/docs/docs.json +44 -23
  30. package/index.d.ts +3 -19
  31. package/javascript/components/MarkerView.tsx +12 -1
  32. package/javascript/components/{NativeBridgeComponent.js → NativeBridgeComponent.tsx} +33 -10
  33. package/javascript/components/PointAnnotation.tsx +231 -0
  34. package/javascript/utils/index.d.ts +11 -3
  35. package/package.json +8 -8
  36. package/scripts/autogenHelpers/DocJSONBuilder.js +68 -12
  37. package/scripts/templates/component.md.ejs +1 -1
  38. package/javascript/components/PointAnnotation.d.ts +0 -13
  39. package/javascript/components/PointAnnotation.js +0 -217
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## props
6
6
  | Prop | Type | Default | Required | Description |
7
- | ---- | :--: | :-----: | :------: | :----------: |
7
+ | ---- | :-- | :----- | :------ | :---------- |
8
8
  | id | `string` | `none` | `true` | FIX ME NO DESCRIPTION |
9
9
  | animated | `bool` | `false` | `false` | FIX ME NO DESCRIPTION |
10
10
  | animationDuration | `number` | `1000` | `false` | FIX ME NO DESCRIPTION |
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## props
6
6
  | Prop | Type | Default | Required | Description |
7
- | ---- | :--: | :-----: | :------: | :----------: |
7
+ | ---- | :-- | :----- | :------ | :---------- |
8
8
  | style | `AtmosphereLayerStyleProps` | `none` | `true` | FIX ME NO DESCRIPTION |
9
9
 
10
10
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## props
6
6
  | Prop | Type | Default | Required | Description |
7
- | ---- | :--: | :-----: | :------: | :----------: |
7
+ | ---- | :-- | :----- | :------ | :---------- |
8
8
  | id | `string` | `none` | `true` | A string that uniquely identifies the source in the style to which it is added. |
9
9
  | sourceID | `string` | `MapboxGL.StyleSource.DefaultSourceID` | `false` | The source from which to obtain the data to style.<br/>If the source has not yet been added to the current style, the behavior is undefined.<br/>Inferred from parent source only if the layer is a direct child to it. |
10
10
  | sourceLayerID | `string` | `none` | `false` | Identifier of the layer within the source identified by the sourceID property from which the receiver obtains the data to style. |
package/docs/Callout.md CHANGED
@@ -4,7 +4,7 @@ Callout that displays information about a selected annotation near the annotatio
4
4
 
5
5
  ## props
6
6
  | Prop | Type | Default | Required | Description |
7
- | ---- | :--: | :-----: | :------: | :----------: |
7
+ | ---- | :-- | :----- | :------ | :---------- |
8
8
  | title | `string` | `none` | `false` | String that gets displayed in the default callout. |
9
9
  | style | `any` | `none` | `false` | Style property for the Animated.View wrapper, apply animations to this |
10
10
  | containerStyle | `any` | `none` | `false` | Style property for the native RCTMGLCallout container, set at your own risk. |
package/docs/Camera.md CHANGED
@@ -20,7 +20,7 @@ return (
20
20
 
21
21
  ## props
22
22
  | Prop | Type | Default | Required | Description |
23
- | ---- | :--: | :-----: | :------: | :----------: |
23
+ | ---- | :-- | :----- | :------ | :---------- |
24
24
  | type | `literal` | `none` | `false` | Allows static check of the data type. For internal use only. |
25
25
  | centerCoordinate | `Position` | `none` | `false` | The location on which the map should center. |
26
26
  | bounds | `intersection` | `none` | `false` | The corners of a box around which the map should bound. Contains padding props for backwards<br/>compatibility; the root `padding` prop should be used instead. |
@@ -4,7 +4,7 @@ CircleLayer is a style layer that renders one or more filled circles on the map.
4
4
 
5
5
  ## props
6
6
  | Prop | Type | Default | Required | Description |
7
- | ---- | :--: | :-----: | :------: | :----------: |
7
+ | ---- | :-- | :----- | :------ | :---------- |
8
8
  | id | `string` | `none` | `true` | A string that uniquely identifies the source in the style to which it is added. |
9
9
  | sourceID | `string` | `MapboxGL.StyleSource.DefaultSourceID` | `false` | The source from which to obtain the data to style.<br/>If the source has not yet been added to the current style, the behavior is undefined.<br/>Inferred from parent source only if the layer is a direct child to it. |
10
10
  | sourceLayerID | `string` | `none` | `false` | Identifier of the layer within the source identified by the sourceID property<br/>from which the receiver obtains the data to style. |
@@ -4,7 +4,7 @@ FillExtrusionLayer is a style layer that renders one or more 3D extruded polygon
4
4
 
5
5
  ## props
6
6
  | Prop | Type | Default | Required | Description |
7
- | ---- | :--: | :-----: | :------: | :----------: |
7
+ | ---- | :-- | :----- | :------ | :---------- |
8
8
  | id | `string` | `none` | `true` | A string that uniquely identifies the source in the style to which it is added. |
9
9
  | sourceID | `string` | `MapboxGL.StyleSource.DefaultSourceID` | `false` | The source from which to obtain the data to style.<br/>If the source has not yet been added to the current style, the behavior is undefined.<br/>Inferred from parent source only if the layer is a direct child to it. |
10
10
  | sourceLayerID | `string` | `none` | `false` | Identifier of the layer within the source identified by the sourceID property from which the receiver obtains the data to style. |
package/docs/FillLayer.md CHANGED
@@ -4,7 +4,7 @@ FillLayer is a style layer that renders one or more filled (and optionally strok
4
4
 
5
5
  ## props
6
6
  | Prop | Type | Default | Required | Description |
7
- | ---- | :--: | :-----: | :------: | :----------: |
7
+ | ---- | :-- | :----- | :------ | :---------- |
8
8
  | id | `string` | `none` | `true` | A string that uniquely identifies the source in the style to which it is added. |
9
9
  | sourceID | `string` | `MapboxGL.StyleSource.DefaultSourceID` | `false` | The source from which to obtain the data to style.<br/>If the source has not yet been added to the current style, the behavior is undefined.<br/>Inferred from parent source only if the layer is a direct child to it. |
10
10
  | sourceLayerID | `string` | `none` | `false` | Identifier of the layer within the source identified by the sourceID property from which the receiver obtains the data to style. |
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## props
6
6
  | Prop | Type | Default | Required | Description |
7
- | ---- | :--: | :-----: | :------: | :----------: |
7
+ | ---- | :-- | :----- | :------ | :---------- |
8
8
  | heading | `number` | `none` | `false` | FIX ME NO DESCRIPTION |
9
9
 
10
10
 
@@ -4,7 +4,7 @@ HeatmapLayer is a style layer that renders one or more filled circles on the map
4
4
 
5
5
  ## props
6
6
  | Prop | Type | Default | Required | Description |
7
- | ---- | :--: | :-----: | :------: | :----------: |
7
+ | ---- | :-- | :----- | :------ | :---------- |
8
8
  | id | `string` | `none` | `true` | A string that uniquely identifies the source in the style to which it is added. |
9
9
  | sourceID | `string` | `MapboxGL.StyleSource.DefaultSourceID` | `false` | The source from which to obtain the data to style.<br/>If the source has not yet been added to the current style, the behavior is undefined.<br/>Inferred from parent source only if the layer is a direct child to it. |
10
10
  | sourceLayerID | `string` | `none` | `false` | Identifier of the layer within the source identified by the sourceID property<br/>from which the receiver obtains the data to style. |
@@ -5,7 +5,7 @@ The georeferenced image scales and rotates as the user zooms and rotates the map
5
5
 
6
6
  ## props
7
7
  | Prop | Type | Default | Required | Description |
8
- | ---- | :--: | :-----: | :------: | :----------: |
8
+ | ---- | :-- | :----- | :------ | :---------- |
9
9
  | id | `string` | `none` | `true` | A string that uniquely identifies the source. |
10
10
  | url | `union` | `none` | `false` | An HTTP(S) URL, absolute file URL, or local file URL to the source image.<br/>Gifs are currently not supported. |
11
11
  | coordinates | `array` | `none` | `true` | The top left, top right, bottom right, and bottom left coordinates for the image. |
package/docs/Images.md CHANGED
@@ -4,7 +4,7 @@ Images defines the images used in Symbol etc. layers.
4
4
 
5
5
  ## props
6
6
  | Prop | Type | Default | Required | Description |
7
- | ---- | :--: | :-----: | :------: | :----------: |
7
+ | ---- | :-- | :----- | :------ | :---------- |
8
8
  | images | `object` | `none` | `false` | Specifies the external images in key-value pairs required for the shape source.<br/>Keys are names - see iconImage expressions, values can be either urls-s objects<br/>with format {uri: 'http://...'}` or `require('image.png')` or `import 'image.png'` |
9
9
  | nativeAssetImages | `array` | `none` | `false` | If you have an asset under Image.xcassets on iOS and the drawables directory on android<br/>you can specify an array of string names with assets as the key `['pin']`. |
10
10
  | onImageMissing | `func` | `none` | `false` | Gets called when a Layer is trying to render an image whose key is not present in<br/>any of the `Images` component of the Map. |
package/docs/Light.md CHANGED
@@ -4,7 +4,7 @@ Light represents the light source for extruded geometries
4
4
 
5
5
  ## props
6
6
  | Prop | Type | Default | Required | Description |
7
- | ---- | :--: | :-----: | :------: | :----------: |
7
+ | ---- | :-- | :----- | :------ | :---------- |
8
8
  | style | `custom` | `none` | `false` | Customizable style attributes |
9
9
 
10
10
 
package/docs/LineLayer.md CHANGED
@@ -4,7 +4,7 @@ LineLayer is a style layer that renders one or more stroked polylines on the map
4
4
 
5
5
  ## props
6
6
  | Prop | Type | Default | Required | Description |
7
- | ---- | :--: | :-----: | :------: | :----------: |
7
+ | ---- | :-- | :----- | :------ | :---------- |
8
8
  | id | `string` | `none` | `true` | A string that uniquely identifies the source in the style to which it is added. |
9
9
  | sourceID | `string` | `MapboxGL.StyleSource.DefaultSourceID` | `false` | The source from which to obtain the data to style.<br/>If the source has not yet been added to the current style, the behavior is undefined.<br/>Inferred from parent source only if the layer is a direct child to it. |
10
10
  | sourceLayerID | `string` | `none` | `false` | Identifier of the layer within the source identified by the sourceID property from which the receiver obtains the data to style. |
package/docs/MapView.md CHANGED
@@ -4,7 +4,7 @@ MapView backed by Mapbox Native GL
4
4
 
5
5
  ## props
6
6
  | Prop | Type | Default | Required | Description |
7
- | ---- | :--: | :-----: | :------: | :----------: |
7
+ | ---- | :-- | :----- | :------ | :---------- |
8
8
  | contentInset | `union` | `none` | `false` | The distance from the edges of the map view’s frame to the edges of the map view’s logical viewport. |
9
9
  | style | `any` | `none` | `false` | Style for wrapping React Native View |
10
10
  | styleURL | `string` | `none` | `false` | Style URL for map - notice, if non is set it _will_ default to `MapboxGL.StyleURL.Street` |
@@ -9,7 +9,7 @@ and PointAnnotation on iOS.
9
9
 
10
10
  ## props
11
11
  | Prop | Type | Default | Required | Description |
12
- | ---- | :--: | :-----: | :------: | :----------: |
12
+ | ---- | :-- | :----- | :------ | :---------- |
13
13
  | coordinate | `tuple` | `none` | `true` | The center point (specified as a map coordinate) of the marker.<br/>See also #anchor. |
14
14
  | anchor | `shape` | `{ x: 0.5, y: 0.5 }` | `false` | Specifies the anchor being set on a particular point of the annotation.<br/>The anchor point is specified in the continuous space [0.0, 1.0] x [0.0, 1.0],<br/>where (0, 0) is the top-left corner of the image, and (1, 1) is the bottom-right corner.<br/>Note this is only for custom annotations not the default pin view.<br/>Defaults to the center of the view. |
15
15
  | &nbsp;&nbsp;x | `number` | `none` | `true` | `x` of anchor |
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## props
6
6
  | Prop | Type | Default | Required | Description |
7
- | ---- | :--: | :-----: | :------: | :----------: |
7
+ | ---- | :-- | :----- | :------ | :---------- |
8
8
  | androidRenderMode | `enum` | `none` | `false` | Android render mode.<br/><br/> - normal: just a circle<br/> - compass: triangle with heading<br/> - gps: large arrow<br/><br/>@platform android |
9
9
  | iosShowsUserHeadingIndicator | `bool` | `none` | `false` | iOS only. A Boolean value indicating whether the user location annotation may display a permanent heading indicator.<br/><br/>@platform ios |
10
10
 
@@ -1,4 +1,4 @@
1
- <!-- This file was autogenerated from PointAnnotation.js do not modify -->
1
+ <!-- This file was autogenerated from PointAnnotation.tsx do not modify -->
2
2
  # <MapboxGL.PointAnnotation />
3
3
  PointAnnotation represents a one-dimensional shape located at a single geographical coordinate.
4
4
 
@@ -10,21 +10,23 @@ as with PointAnnotation on Android child views are rendered onto a bitmap for be
10
10
 
11
11
  ## props
12
12
  | Prop | Type | Default | Required | Description |
13
- | ---- | :--: | :-----: | :------: | :----------: |
13
+ | ---- | :-- | :----- | :------ | :---------- |
14
14
  | id | `string` | `none` | `true` | A string that uniquely identifies the annotation |
15
15
  | title | `string` | `none` | `false` | The string containing the annotation’s title. Note this is required to be set if you want to see a callout appear on iOS. |
16
16
  | snippet | `string` | `none` | `false` | The string containing the annotation’s snippet(subtitle). Not displayed in the default callout. |
17
- | selected | `bool` | `none` | `false` | Manually selects/deselects annotation<br/>@type {[type]} |
18
- | draggable | `bool` | `false` | `false` | Enable or disable dragging. Defaults to false. |
19
- | coordinate | `array` | `none` | `true` | The center point (specified as a map coordinate) of the annotation. |
17
+ | selected | `boolean` | `none` | `false` | Manually selects/deselects annotation |
18
+ | draggable | `boolean` | `false` | `false` | Enable or disable dragging. Defaults to false. |
19
+ | coordinate | `tuple` | `none` | `true` | The center point (specified as a map coordinate) of the annotation. |
20
20
  | anchor | `shape` | `{ x: 0.5, y: 0.5 }` | `false` | Specifies the anchor being set on a particular point of the annotation.<br/>The anchor point is specified in the continuous space [0.0, 1.0] x [0.0, 1.0],<br/>where (0, 0) is the top-left corner of the image, and (1, 1) is the bottom-right corner.<br/>Note this is only for custom annotations not the default pin view.<br/>Defaults to the center of the view. |
21
21
  | &nbsp;&nbsp;x | `number` | `none` | `true` | See anchor |
22
22
  | &nbsp;&nbsp;y | `number` | `none` | `true` | See anchor |
23
- | onSelected | `func` | `none` | `false` | This callback is fired once this annotation is selected. Returns a Feature as the first param. |
24
- | onDeselected | `func` | `none` | `false` | This callback is fired once this annotation is deselected. |
25
- | onDragStart | `func` | `none` | `false` | This callback is fired once this annotation has started being dragged. |
26
- | onDragEnd | `func` | `none` | `false` | This callback is fired once this annotation has stopped being dragged. |
27
- | onDrag | `func` | `none` | `false` | This callback is fired while this annotation is being dragged. |
23
+ | onSelected | `func` | `none` | `false` | This callback is fired once this annotation is selected. Returns a Feature as the first param.<br/>*signature:*`(payload:{feature: Feature}) => void` |
24
+ | onDeselected | `func` | `none` | `false` | This callback is fired once this annotation is deselected.<br/>*signature:*`(payload:{feature: Feature}) => void` |
25
+ | onDragStart | `func` | `none` | `false` | This callback is fired once this annotation has started being dragged.<br/>*signature:*`(payload:{feature: Feature}) => void` |
26
+ | onDragEnd | `func` | `none` | `false` | This callback is fired once this annotation has stopped being dragged.<br/>*signature:*`(payload:{feature: Feature}) => void` |
27
+ | onDrag | `func` | `none` | `false` | This callback is fired while this annotation is being dragged.<br/>*signature:*`(payload:{feature: Feature}) => void` |
28
+ | children | `ReactReactElement` | `none` | `true` | Expects one child, and an optional callout can be added as well |
29
+ | style | `ViewProps['style']` | `none` | `false` | FIX ME NO DESCRIPTION |
28
30
 
29
31
  ## methods
30
32
  ### refresh()
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## props
6
6
  | Prop | Type | Default | Required | Description |
7
- | ---- | :--: | :-----: | :------: | :----------: |
7
+ | ---- | :-- | :----- | :------ | :---------- |
8
8
  | id | `string` | `MapboxGL.StyleSource.DefaultSourceID` | `false` | A string that uniquely identifies the source. |
9
9
  | url | `string` | `none` | `false` | A URL to a TileJSON configuration file describing the source’s contents and other metadata. |
10
10
  | tileUrlTemplates | `array` | `none` | `false` | An array of tile URL templates. If multiple endpoints are specified, clients may use any combination of endpoints.<br/>Example: https://example.com/raster-tiles/{z}/{x}/{y}.png |
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## props
6
6
  | Prop | Type | Default | Required | Description |
7
- | ---- | :--: | :-----: | :------: | :----------: |
7
+ | ---- | :-- | :----- | :------ | :---------- |
8
8
  | id | `string` | `none` | `true` | A string that uniquely identifies the source in the style to which it is added. |
9
9
  | sourceID | `string` | `MapboxGL.StyleSource.DefaultSourceID` | `false` | The source from which to obtain the data to style.<br/>If the source has not yet been added to the current style, the behavior is undefined.<br/>Inferred from parent source only if the layer is a direct child to it. |
10
10
  | sourceLayerID | `string` | `none` | `false` | Identifier of the layer within the source identified by the sourceID property from which the receiver obtains the data to style. |
@@ -6,7 +6,7 @@ or by an external file that conforms to the TileJSON specification.
6
6
 
7
7
  ## props
8
8
  | Prop | Type | Default | Required | Description |
9
- | ---- | :--: | :-----: | :------: | :----------: |
9
+ | ---- | :-- | :----- | :------ | :---------- |
10
10
  | id | `string` | `MapboxGL.StyleSource.DefaultSourceID` | `false` | A string that uniquely identifies the source. |
11
11
  | url | `string` | `none` | `false` | A URL to a TileJSON configuration file describing the source’s contents and other metadata. |
12
12
  | tileUrlTemplates | `array` | `none` | `false` | An array of tile URL templates. If multiple endpoints are specified, clients may use any combination of endpoints.<br/>Example: https://example.com/raster-tiles/{z}/{x}/{y}.png |
@@ -5,7 +5,7 @@ The shape may be an url or a GeoJSON object
5
5
 
6
6
  ## props
7
7
  | Prop | Type | Default | Required | Description |
8
- | ---- | :--: | :-----: | :------: | :----------: |
8
+ | ---- | :-- | :----- | :------ | :---------- |
9
9
  | id | `string` | `MapboxGL.StyleSource.DefaultSourceID` | `false` | A string that uniquely identifies the source. |
10
10
  | url | `string` | `none` | `false` | An HTTP(S) URL, absolute file URL, or local file URL relative to the current application’s resource bundle. |
11
11
  | shape | `object` | `none` | `false` | The contents of the source. A shape can represent a GeoJSON geometry, a feature, or a feature collection. |
package/docs/SkyLayer.md CHANGED
@@ -4,7 +4,7 @@ SkyLayer is a spherical dome around the map that is always rendered behind all o
4
4
 
5
5
  ## props
6
6
  | Prop | Type | Default | Required | Description |
7
- | ---- | :--: | :-----: | :------: | :----------: |
7
+ | ---- | :-- | :----- | :------ | :---------- |
8
8
  | id | `string` | `none` | `true` | A string that uniquely identifies the source in the style to which it is added. |
9
9
  | sourceID | `string` | `MapboxGL.StyleSource.DefaultSourceID` | `false` | The source from which to obtain the data to style.<br/>If the source has not yet been added to the current style, the behavior is undefined. |
10
10
  | aboveLayerID | `string` | `none` | `false` | Inserts a layer above aboveLayerID. |
package/docs/Style.md CHANGED
@@ -6,7 +6,7 @@ Other fields such as `sprites`, `glyphs` etc. will be ignored. Not all layer / s
6
6
 
7
7
  ## props
8
8
  | Prop | Type | Default | Required | Description |
9
- | ---- | :--: | :-----: | :------: | :----------: |
9
+ | ---- | :-- | :----- | :------ | :---------- |
10
10
  | json | `any` | `none` | `false` | A JSON object conforming to the schema described in the Mapbox Style Specification , or a URL to such JSON. |
11
11
 
12
12
 
@@ -4,7 +4,7 @@ SymbolLayer is a style layer that renders icon and text labels at points or alon
4
4
 
5
5
  ## props
6
6
  | Prop | Type | Default | Required | Description |
7
- | ---- | :--: | :-----: | :------: | :----------: |
7
+ | ---- | :-- | :----- | :------ | :---------- |
8
8
  | id | `string` | `none` | `true` | A string that uniquely identifies the source in the style to which it is added. |
9
9
  | sourceID | `string` | `MapboxGL.StyleSource.DefaultSourceID` | `false` | The source from which to obtain the data to style.<br/>If the source has not yet been added to the current style, the behavior is undefined.<br/>Inferred from parent source only if the layer is a direct child to it. |
10
10
  | sourceLayerID | `string` | `none` | `false` | Identifier of the layer within the source identified by the sourceID property from which the receiver obtains the data to style. |
package/docs/Terrain.md CHANGED
@@ -4,7 +4,7 @@ A global modifier that elevates layers and markers based on a DEM data source.
4
4
 
5
5
  ## props
6
6
  | Prop | Type | Default | Required | Description |
7
- | ---- | :--: | :-----: | :------: | :----------: |
7
+ | ---- | :-- | :----- | :------ | :---------- |
8
8
  | sourceID | `string` | `MapboxGL.StyleSource.DefaultSourceID` | `false` | Name of a source of raster_dem type to be used for terrain elevation. |
9
9
  | exaggeration | `union` | `none` | `false` | Optional number between 0 and 1000 inclusive. Defaults to 1. Supports interpolateexpressions. Transitionable.<br/>Exaggerates the elevation of the terrain by multiplying the data from the DEM with this value. |
10
10
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## props
6
6
  | Prop | Type | Default | Required | Description |
7
- | ---- | :--: | :-----: | :------: | :----------: |
7
+ | ---- | :-- | :----- | :------ | :---------- |
8
8
  | animated | `bool` | `true` | `false` | Whether location icon is animated between updates |
9
9
  | renderMode | `enum` | `'normal'` | `false` | Which render mode to use.<br/>Can either be `normal` or `native` |
10
10
  | androidRenderMode | `enum` | `none` | `false` | native/android only render mode<br/><br/> - normal: just a circle<br/> - compass: triangle with heading<br/> - gps: large arrow<br/><br/>@platform android |
@@ -5,7 +5,7 @@ The location of and metadata about the tiles are defined either by an option dic
5
5
 
6
6
  ## props
7
7
  | Prop | Type | Default | Required | Description |
8
- | ---- | :--: | :-----: | :------: | :----------: |
8
+ | ---- | :-- | :----- | :------ | :---------- |
9
9
  | id | `string` | `MapboxGL.StyleSource.DefaultSourceID` | `false` | A string that uniquely identifies the source. |
10
10
  | url | `string` | `none` | `false` | A URL to a TileJSON configuration file describing the source’s contents and other metadata. |
11
11
  | tileUrlTemplates | `array` | `none` | `false` | An array of tile URL templates. If multiple endpoints are specified, clients may use any combination of endpoints.<br/>Example: https://example.com/vector-tiles/{z}/{x}/{y}.pbf |
package/docs/docs.json CHANGED
@@ -3292,26 +3292,21 @@
3292
3292
  {
3293
3293
  "name": "selected",
3294
3294
  "required": false,
3295
- "type": "bool",
3295
+ "type": "boolean",
3296
3296
  "default": "none",
3297
- "description": "Manually selects/deselects annotation\n@type {[type]}"
3297
+ "description": "Manually selects/deselects annotation"
3298
3298
  },
3299
3299
  {
3300
3300
  "name": "draggable",
3301
3301
  "required": false,
3302
- "type": "bool",
3302
+ "type": "boolean",
3303
3303
  "default": "false",
3304
3304
  "description": "Enable or disable dragging. Defaults to false."
3305
3305
  },
3306
3306
  {
3307
3307
  "name": "coordinate",
3308
3308
  "required": true,
3309
- "type": {
3310
- "name": "array",
3311
- "value": {
3312
- "type": "number"
3313
- }
3314
- },
3309
+ "type": "tuple",
3315
3310
  "default": "none",
3316
3311
  "description": "The center point (specified as a map coordinate) of the annotation."
3317
3312
  },
@@ -3343,43 +3338,69 @@
3343
3338
  {
3344
3339
  "name": "onSelected",
3345
3340
  "required": false,
3346
- "type": "func",
3341
+ "type": {
3342
+ "name": "func",
3343
+ "funcSignature": "(payload:{feature: Feature}) => void"
3344
+ },
3347
3345
  "default": "none",
3348
- "description": "This callback is fired once this annotation is selected. Returns a Feature as the first param."
3346
+ "description": "This callback is fired once this annotation is selected. Returns a Feature as the first param.\n*signature:*`(payload:{feature: Feature}) => void`"
3349
3347
  },
3350
3348
  {
3351
3349
  "name": "onDeselected",
3352
3350
  "required": false,
3353
- "type": "func",
3351
+ "type": {
3352
+ "name": "func",
3353
+ "funcSignature": "(payload:{feature: Feature}) => void"
3354
+ },
3354
3355
  "default": "none",
3355
- "description": "This callback is fired once this annotation is deselected."
3356
+ "description": "This callback is fired once this annotation is deselected.\n*signature:*`(payload:{feature: Feature}) => void`"
3356
3357
  },
3357
3358
  {
3358
3359
  "name": "onDragStart",
3359
3360
  "required": false,
3360
- "type": "func",
3361
+ "type": {
3362
+ "name": "func",
3363
+ "funcSignature": "(payload:{feature: Feature}) => void"
3364
+ },
3361
3365
  "default": "none",
3362
- "description": "This callback is fired once this annotation has started being dragged."
3366
+ "description": "This callback is fired once this annotation has started being dragged.\n*signature:*`(payload:{feature: Feature}) => void`"
3363
3367
  },
3364
3368
  {
3365
3369
  "name": "onDragEnd",
3366
3370
  "required": false,
3367
- "type": "func",
3371
+ "type": {
3372
+ "name": "func",
3373
+ "funcSignature": "(payload:{feature: Feature}) => void"
3374
+ },
3368
3375
  "default": "none",
3369
- "description": "This callback is fired once this annotation has stopped being dragged."
3376
+ "description": "This callback is fired once this annotation has stopped being dragged.\n*signature:*`(payload:{feature: Feature}) => void`"
3370
3377
  },
3371
3378
  {
3372
3379
  "name": "onDrag",
3373
3380
  "required": false,
3374
- "type": "func",
3381
+ "type": {
3382
+ "name": "func",
3383
+ "funcSignature": "(payload:{feature: Feature}) => void"
3384
+ },
3385
+ "default": "none",
3386
+ "description": "This callback is fired while this annotation is being dragged.\n*signature:*`(payload:{feature: Feature}) => void`"
3387
+ },
3388
+ {
3389
+ "name": "children",
3390
+ "required": true,
3391
+ "type": "ReactReactElement",
3392
+ "default": "none",
3393
+ "description": "Expects one child, and an optional callout can be added as well"
3394
+ },
3395
+ {
3396
+ "name": "style",
3397
+ "required": false,
3398
+ "type": "ViewProps['style']",
3375
3399
  "default": "none",
3376
- "description": "This callback is fired while this annotation is being dragged."
3400
+ "description": "FIX ME NO DESCRIPTION"
3377
3401
  }
3378
3402
  ],
3379
- "composes": [
3380
- "../utils"
3381
- ],
3382
- "fileNameWithExt": "PointAnnotation.js",
3403
+ "fileNameWithExt": "PointAnnotation.tsx",
3383
3404
  "name": "PointAnnotation"
3384
3405
  },
3385
3406
  "RasterDemSource": {
package/index.d.ts CHANGED
@@ -34,6 +34,7 @@ import {
34
34
  CameraAnimationMode as _CameraAnimationMode,
35
35
  } from './javascript/components/Camera';
36
36
  import { MarkerView as _MarkerView } from './javascript/components/MarkerView';
37
+ import { PointAnnotation as _PointAnnotation } from './javascript/components/PointAnnotation';
37
38
  import { Atmosphere as _Atmosphere } from './javascript/components/Atmosphere';
38
39
  import type {
39
40
  MapboxGLEvent as _MapboxGLEvent,
@@ -140,6 +141,7 @@ declare namespace MapboxGL {
140
141
 
141
142
  const Atmosphere = _Atmosphere;
142
143
  const MarkerView = _MarkerView;
144
+ const PointAnnotation = _PointAnnotation;
143
145
 
144
146
  type MapboxGLEvent = _MapboxGLEvent;
145
147
  type UserTrackingMode = _UserTrackingMode;
@@ -349,9 +351,6 @@ declare namespace MapboxGL {
349
351
  identity(attributeName: string): number;
350
352
  }
351
353
 
352
- class PointAnnotation extends Component<PointAnnotationProps> {
353
- refresh(): void;
354
- }
355
354
  class Callout extends Component<CalloutProps> {}
356
355
  type Style = React.FC<StyleProps>;
357
356
 
@@ -849,22 +848,6 @@ export interface LightProps extends Omit<ViewProps, 'style'> {
849
848
  style?: LightStyle;
850
849
  }
851
850
 
852
- export interface PointAnnotationProps {
853
- id: string;
854
- title?: string;
855
- snippet?: string;
856
- selected?: boolean;
857
- draggable?: boolean;
858
- coordinate: GeoJSON.Position;
859
- anchor?: Point;
860
- children: JSX.Element;
861
- onSelected?: () => void;
862
- onDeselected?: () => void;
863
- onDragStart?: () => void;
864
- onDrag?: () => void;
865
- onDragEnd?: () => void;
866
- }
867
-
868
851
  export interface StyleProps {
869
852
  json: any;
870
853
  }
@@ -1051,6 +1034,7 @@ export import SymbolLayer = MapboxGL.SymbolLayer;
1051
1034
  export import RasterLayer = MapboxGL.RasterLayer;
1052
1035
  export import BackgroundLayer = MapboxGL.BackgroundLayer;
1053
1036
  export import MarkerView = MapboxGL.MarkerView;
1037
+ export import PointAnnotation = MapboxGL.PointAnnotation;
1054
1038
 
1055
1039
  export import MapboxGLEvent = MapboxGL.MapboxGLEvent;
1056
1040
  export import UserTrackingMode = MapboxGL.UserTrackingMode;
@@ -58,10 +58,21 @@ class MarkerView extends React.PureComponent<{
58
58
  anchor: { x: 0.5, y: 0.5 },
59
59
  };
60
60
 
61
+ static lastId = 0;
62
+ __idForPointAnnotation?: string;
63
+
64
+ _idForPointAnnotation(): string {
65
+ if (this.__idForPointAnnotation === undefined) {
66
+ MarkerView.lastId = MarkerView.lastId + 1;
67
+ this.__idForPointAnnotation = `MV-${MarkerView.lastId}`;
68
+ }
69
+ return this.__idForPointAnnotation;
70
+ }
71
+
61
72
  render() {
62
73
  const { props } = this;
63
74
  if (Platform.OS === 'ios' && !Mapbox.MapboxV10) {
64
- return <PointAnnotation {...props} />;
75
+ return <PointAnnotation id={this._idForPointAnnotation()} {...props} />;
65
76
  }
66
77
 
67
78
  function _getCoordinate(coordinate: [number, number]): string | undefined {
@@ -1,27 +1,46 @@
1
+ import React from 'react';
2
+
1
3
  import { runNativeCommand, isAndroid } from '../utils';
2
4
 
3
5
  let callbackIncrement = 0;
4
6
 
5
- const NativeBridgeComponent = (B) =>
7
+ export type RNMBEvent<PayloadType = { [key: string]: string }> = {
8
+ payload: PayloadType;
9
+ type: string;
10
+ };
11
+
12
+ const NativeBridgeComponent = <T,>(B: React.ComponentClass<T>) =>
6
13
  class extends B {
7
- constructor(props, nativeModuleName) {
14
+ _nativeModuleName: string;
15
+ _onAndroidCallback: (e: any) => void;
16
+ _callbackMap: Map<string, any>;
17
+ _preRefMapMethodQueue: Array<{
18
+ method: { name: string; args: Array<string> };
19
+ resolver: (value: unknown) => void;
20
+ }>;
21
+
22
+ constructor(props: T, nativeModuleName: string) {
8
23
  super(props);
9
24
 
10
25
  this._nativeModuleName = nativeModuleName;
11
- this._onAndroidCallback = this._onAndroidCallback.bind(this);
26
+ this._onAndroidCallback = this._onAndroidCallbackO.bind(this);
12
27
  this._callbackMap = new Map();
13
28
  this._preRefMapMethodQueue = [];
14
29
  }
15
30
 
16
- _addAddAndroidCallback(id, resolve, reject) {
31
+ _addAddAndroidCallback(
32
+ id: string,
33
+ resolve: (value: string) => void,
34
+ reject: (error: Error) => void,
35
+ ) {
17
36
  this._callbackMap.set(id, { resolve, reject });
18
37
  }
19
38
 
20
- _removeAndroidCallback(id) {
21
- this._callbackMap.remove(id);
39
+ _removeAndroidCallback(id: string) {
40
+ this._callbackMap.delete(id);
22
41
  }
23
42
 
24
- _onAndroidCallback(e) {
43
+ _onAndroidCallbackO(e: React.SyntheticEvent<Element, RNMBEvent>) {
25
44
  const callbackID = e.nativeEvent.type;
26
45
  const callback = this._callbackMap.get(callbackID);
27
46
 
@@ -30,7 +49,7 @@ const NativeBridgeComponent = (B) =>
30
49
  }
31
50
 
32
51
  this._callbackMap.delete(callbackID);
33
- let { payload } = e.nativeEvent;
52
+ const { payload } = e.nativeEvent;
34
53
  if (payload.error) {
35
54
  callback.reject.call(null, new Error(payload.error));
36
55
  } else {
@@ -38,7 +57,7 @@ const NativeBridgeComponent = (B) =>
38
57
  }
39
58
  }
40
59
 
41
- async _runPendingNativeCommands(nativeRef) {
60
+ async _runPendingNativeCommands<RefType>(nativeRef: RefType) {
42
61
  if (nativeRef) {
43
62
  while (this._preRefMapMethodQueue.length > 0) {
44
63
  const item = this._preRefMapMethodQueue.pop();
@@ -55,7 +74,11 @@ const NativeBridgeComponent = (B) =>
55
74
  }
56
75
  }
57
76
 
58
- _runNativeCommand(methodName, nativeRef, args = []) {
77
+ _runNativeCommand<RefType>(
78
+ methodName: string,
79
+ nativeRef: RefType,
80
+ args: string[] = [],
81
+ ) {
59
82
  if (!nativeRef) {
60
83
  return new Promise((resolve) => {
61
84
  this._preRefMapMethodQueue.push({
@@ -0,0 +1,231 @@
1
+ import React, { SyntheticEvent, type Component } from 'react';
2
+ import {
3
+ requireNativeComponent,
4
+ StyleSheet,
5
+ Platform,
6
+ type HostComponent,
7
+ type ViewProps,
8
+ } from 'react-native';
9
+ import { type Feature } from 'geojson';
10
+
11
+ import { toJSONString, isFunction } from '../utils';
12
+ import { makePoint } from '../utils/geoUtils';
13
+
14
+ import NativeBridgeComponent, { type RNMBEvent } from './NativeBridgeComponent';
15
+
16
+ export const NATIVE_MODULE_NAME = 'RCTMGLPointAnnotation';
17
+
18
+ const styles = StyleSheet.create({
19
+ container: {
20
+ alignItems: 'center',
21
+ justifyContent: 'center',
22
+ position: 'absolute',
23
+ },
24
+ });
25
+
26
+ type FeaturePayload = {
27
+ feature: Feature;
28
+ };
29
+
30
+ type PointAnnotationProps = {
31
+ /**
32
+ * A string that uniquely identifies the annotation
33
+ */
34
+ id: string;
35
+
36
+ /**
37
+ * The string containing the annotation’s title. Note this is required to be set if you want to see a callout appear on iOS.
38
+ */
39
+ title?: string;
40
+
41
+ /**
42
+ * The string containing the annotation’s snippet(subtitle). Not displayed in the default callout.
43
+ */
44
+ snippet?: string;
45
+
46
+ /**
47
+ * Manually selects/deselects annotation
48
+ */
49
+ selected?: boolean;
50
+
51
+ /**
52
+ * Enable or disable dragging. Defaults to false.
53
+ */
54
+ draggable?: boolean;
55
+
56
+ /**
57
+ * The center point (specified as a map coordinate) of the annotation.
58
+ */
59
+ coordinate: [number, number];
60
+
61
+ /**
62
+ * Specifies the anchor being set on a particular point of the annotation.
63
+ * The anchor point is specified in the continuous space [0.0, 1.0] x [0.0, 1.0],
64
+ * where (0, 0) is the top-left corner of the image, and (1, 1) is the bottom-right corner.
65
+ * Note this is only for custom annotations not the default pin view.
66
+ * Defaults to the center of the view.
67
+ */
68
+ anchor?: {
69
+ /**
70
+ * See anchor
71
+ */
72
+ x: number;
73
+ /**
74
+ * See anchor
75
+ */
76
+ y: number;
77
+ };
78
+
79
+ /**
80
+ * This callback is fired once this annotation is selected. Returns a Feature as the first param.
81
+ */
82
+ onSelected?: (payload: FeaturePayload) => void;
83
+
84
+ /**
85
+ * This callback is fired once this annotation is deselected.
86
+ */
87
+ onDeselected?: (payload: FeaturePayload) => void;
88
+
89
+ /**
90
+ * This callback is fired once this annotation has started being dragged.
91
+ */
92
+ onDragStart?: (payload: FeaturePayload) => void;
93
+
94
+ /**
95
+ * This callback is fired once this annotation has stopped being dragged.
96
+ */
97
+ onDragEnd?: (payload: FeaturePayload) => void;
98
+
99
+ /**
100
+ * This callback is fired while this annotation is being dragged.
101
+ */
102
+ onDrag?: (payload: FeaturePayload) => void;
103
+
104
+ /**
105
+ * Expects one child, and an optional callout can be added as well
106
+ */
107
+ children: React.ReactElement;
108
+
109
+ style?: ViewProps['style'];
110
+ };
111
+
112
+ /**
113
+ * PointAnnotation represents a one-dimensional shape located at a single geographical coordinate.
114
+ *
115
+ * Consider using ShapeSource and SymbolLayer instead, if you have many points and you have static images,
116
+ * they'll offer much better performance.
117
+ *
118
+ * If you need interactive views please use MarkerView,
119
+ * as with PointAnnotation on Android child views are rendered onto a bitmap for better performance.
120
+ */
121
+ class PointAnnotation extends NativeBridgeComponent(
122
+ React.PureComponent<PointAnnotationProps>,
123
+ ) {
124
+ static defaultProps = {
125
+ anchor: { x: 0.5, y: 0.5 },
126
+ draggable: false,
127
+ };
128
+
129
+ _nativeRef: NativePointAnnotationRef | null = null;
130
+
131
+ constructor(props: PointAnnotationProps) {
132
+ super(props, NATIVE_MODULE_NAME);
133
+ this._onSelected = this._onSelected.bind(this);
134
+ this._onDeselected = this._onDeselected.bind(this);
135
+ this._onDragStart = this._onDragStart.bind(this);
136
+ this._onDrag = this._onDrag.bind(this);
137
+ this._onDragEnd = this._onDragEnd.bind(this);
138
+ }
139
+
140
+ _onSelected(e: SyntheticEvent<Element, RNMBEvent<FeaturePayload>>) {
141
+ if (isFunction(this.props.onSelected)) {
142
+ this.props.onSelected(e.nativeEvent.payload);
143
+ }
144
+ }
145
+
146
+ _onDeselected(e: SyntheticEvent<Element, RNMBEvent<FeaturePayload>>) {
147
+ if (isFunction(this.props.onDeselected)) {
148
+ this.props.onDeselected(e.nativeEvent.payload);
149
+ }
150
+ }
151
+
152
+ _onDragStart(e: SyntheticEvent<Element, RNMBEvent<FeaturePayload>>) {
153
+ if (isFunction(this.props.onDragStart)) {
154
+ this.props.onDragStart(e.nativeEvent.payload);
155
+ }
156
+ }
157
+
158
+ _onDrag(e: SyntheticEvent<Element, RNMBEvent<FeaturePayload>>) {
159
+ if (isFunction(this.props.onDrag)) {
160
+ this.props.onDrag(e.nativeEvent.payload);
161
+ }
162
+ }
163
+
164
+ _onDragEnd(e: SyntheticEvent<Element, RNMBEvent<FeaturePayload>>) {
165
+ if (isFunction(this.props.onDragEnd)) {
166
+ this.props.onDragEnd(e.nativeEvent.payload);
167
+ }
168
+ }
169
+
170
+ _getCoordinate(): string | undefined {
171
+ if (!this.props.coordinate) {
172
+ return undefined;
173
+ }
174
+ return toJSONString(makePoint(this.props.coordinate));
175
+ }
176
+
177
+ /**
178
+ * On v10 and pre v10 android point annotation is rendered offscreen with a canvas into an image.
179
+ * To rerender the image from the current state of the view call refresh.
180
+ * Call this for example from Image#onLoad.
181
+ */
182
+ refresh() {
183
+ if (Platform.OS === 'android') {
184
+ this._runNativeCommand('refresh', this._nativeRef, []);
185
+ } else {
186
+ this._runNativeCommand('refresh', this._nativeRef, []);
187
+ }
188
+ }
189
+
190
+ _setNativeRef(nativeRef: NativePointAnnotationRef | null) {
191
+ this._nativeRef = nativeRef;
192
+ super._runPendingNativeCommands(nativeRef);
193
+ }
194
+
195
+ render() {
196
+ const props = {
197
+ ...this.props,
198
+ ref: (nativeRef: NativePointAnnotationRef | null) =>
199
+ this._setNativeRef(nativeRef),
200
+ id: this.props.id,
201
+ title: this.props.title,
202
+ snippet: this.props.snippet,
203
+ anchor: this.props.anchor,
204
+ selected: this.props.selected,
205
+ draggable: this.props.draggable,
206
+ style: [this.props.style, styles.container],
207
+ onMapboxPointAnnotationSelected: this._onSelected,
208
+ onMapboxPointAnnotationDeselected: this._onDeselected,
209
+ onMapboxPointAnnotationDragStart: this._onDragStart,
210
+ onMapboxPointAnnotationDrag: this._onDrag,
211
+ onMapboxPointAnnotationDragEnd: this._onDragEnd,
212
+ coordinate: this._getCoordinate(),
213
+ };
214
+ return (
215
+ <RCTMGLPointAnnotation {...props}>
216
+ {this.props.children}
217
+ </RCTMGLPointAnnotation>
218
+ );
219
+ }
220
+ }
221
+ type NativePointAnnotationProps = Omit<PointAnnotationProps, 'coordinate'> & {
222
+ coordinate: string | undefined;
223
+ };
224
+
225
+ type NativePointAnnotationRef = Component<NativePointAnnotationProps>;
226
+ type NativePointAnnotation = HostComponent<NativePointAnnotationProps>;
227
+
228
+ const RCTMGLPointAnnotation: NativePointAnnotation =
229
+ requireNativeComponent(NATIVE_MODULE_NAME);
230
+
231
+ export default PointAnnotation;
@@ -1,6 +1,14 @@
1
1
  export function isAndroid(): boolean;
2
- export function isBoolean(_: unknown): boolean;
3
- export function isNumber(_: unknown): boolean;
4
- export function isString(_: unknown): boolean;
2
+ export function isBoolean(_: unknown): argument is boolean;
3
+ export function isNumber(_: unknown): argument is number;
4
+ export function isString(_: unknown): argument is string;
5
+ // eslint-disable-next-line @typescript-eslint/ban-types
6
+ export function isFunction(argument: unknown): argument is Function;
5
7
 
6
8
  export function toJSONString(_: unknown): string;
9
+ export function runNativeCommand<RefType>(
10
+ module: string,
11
+ name: string,
12
+ nativeRef: RefType,
13
+ args: string[],
14
+ ): void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rnmapbox/maps",
3
3
  "description": "A Mapbox react native module for creating custom maps",
4
- "version": "10.0.0-beta.39",
4
+ "version": "10.0.0-beta.40",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -62,17 +62,17 @@
62
62
  "deprecated-react-native-prop-types": "^2.3.0"
63
63
  },
64
64
  "devDependencies": {
65
- "@babel/core": "7.17.5",
66
- "@babel/eslint-parser": "^7.17.0",
67
- "@babel/plugin-proposal-class-properties": "7.16.7",
68
- "@babel/runtime": "7.17.2",
65
+ "@babel/core": "7.19.1",
66
+ "@babel/eslint-parser": "^7.19.1",
67
+ "@babel/plugin-proposal-class-properties": "7.18.6",
68
+ "@babel/runtime": "7.19.0",
69
69
  "@react-native-community/eslint-config": "^3.0.1",
70
70
  "@sinonjs/fake-timers": "^8.0.1",
71
71
  "@testing-library/react-native": "^11.0.0",
72
72
  "@types/mapbox-gl": "^2.7.5",
73
73
  "@types/react-native": ">=0.59.9",
74
- "@typescript-eslint/eslint-plugin": "^5.36.2",
75
- "@typescript-eslint/parser": "^5.36.2",
74
+ "@typescript-eslint/eslint-plugin": "^5.37.0",
75
+ "@typescript-eslint/parser": "^5.37.0",
76
76
  "babel-jest": "^27.5.1",
77
77
  "documentation": "13.2.5",
78
78
  "ejs": "^3.1.3",
@@ -90,7 +90,7 @@
90
90
  "mapbox-gl": "^2.9.0",
91
91
  "metro-react-native-babel-preset": "0.71.1",
92
92
  "node-dir": "0.1.17",
93
- "prettier": "2.6.2",
93
+ "prettier": "2.7.1",
94
94
  "react": "17.0.2",
95
95
  "react-docgen": "rnmapbox/react-docgen#rnmapbox-dist",
96
96
  "react-native": "0.67.0",
@@ -22,6 +22,7 @@ const IGNORE_FILES = [
22
22
  'AbstractLayer',
23
23
  'AbstractSource',
24
24
  'NativeBridgeComponent',
25
+ 'NativeBridgeComponent.tsx',
25
26
  ];
26
27
  const IGNORE_PATTERN = /\.web\./;
27
28
 
@@ -143,29 +144,77 @@ class DocJSONBuilder {
143
144
  }
144
145
  }
145
146
 
147
+ /**
148
+ * @typedef {{arguments: {type:TSType,name:string}[], return: TSType]}} TSFuncSignature
149
+ * @typedef {{key:string, value:TSType}[]} TSKVProperties
150
+ * @typedef {{properties: TSKVProperties}} TSObjectSignature
151
+ * @typedef {{name: 'void'}} TSVoidType
152
+ * @typedef {{name: string}} TSTypeType
153
+ * @typedef {{name: 'signature', type:'function', raw:string, signature: TSFuncSignature}} TSFunctionType
154
+ * @typedef {{name: 'signature', type:'object', raw:string, signature: TSObjectSignature}} TSObjectType
155
+ * @typedef {TSVoidType | TSFunctionType | TSTypeType | TSObjectType} TSType
156
+ */
157
+
158
+ /**
159
+ * @params {TSType} tsType
160
+ * @returns {tsType is TSFunctionType}
161
+ */
162
+ function tsTypeIsFunction(tsType) {
163
+ return tsType.type === 'function';
164
+ }
165
+
166
+ /**
167
+ * @params {TSType} tsType
168
+ * @returns {tsType is TSObjectType}
169
+ */
170
+ function tsTypeIsObject(tsType) {
171
+ return tsType.type === 'object';
172
+ }
173
+
174
+ /**
175
+ * @param {TSType} tsType
176
+ */
177
+ function tsTypeDump(tsType) {
178
+ if (tsTypeIsFunction(tsType)) {
179
+ let { signature } = tsType;
180
+ return `(${signature.arguments
181
+ .map(({ name, type }) => `${name}:${tsTypeDump(type)}`)
182
+ .join(', ')}) => ${tsTypeDump(signature.return)}`;
183
+ } else if (tsTypeIsObject(tsType)) {
184
+ let { signature } = tsType;
185
+ return `{${signature.properties
186
+ .map(({ key, value }) => `${key}: ${tsTypeDump(value)}`)
187
+ .join(', ')}}`;
188
+ } else {
189
+ return tsType.name;
190
+ }
191
+ }
192
+
146
193
  function tsTypeDescType(tsType) {
147
194
  if (!tsType?.name) {
148
195
  return null;
149
196
  }
150
197
 
151
- if (tsType.name === 'signature') {
198
+ if (tsType.name === 'signature' && tsType.type === 'object') {
152
199
  const { properties } = tsType.signature;
153
- const value = properties.map((kv) => {
154
- return mapProp(
155
- mapNestedProp({ ...kv.value, description: kv.description }),
156
- kv.key,
157
- false,
158
- );
159
- });
160
- return { name: 'shape', value };
161
- /*
162
- if (tsType.raw.length < 200) {
200
+ if (properties) {
201
+ const value = properties.map((kv) => {
202
+ return mapProp(
203
+ mapNestedProp({ ...kv.value, description: kv.description }),
204
+ kv.key,
205
+ false,
206
+ );
207
+ });
208
+ return { name: 'shape', value };
209
+ } else if (tsType.raw.length < 200) {
163
210
  return `${tsType.raw
164
211
  .replace(/(\n|\s)/g, '')
165
212
  .replace(/(\|)/g, '\\|')}`;
166
213
  } else {
167
214
  return 'FIX ME FORMAT BIG OBJECT';
168
- } */
215
+ }
216
+ } else if (tsType.name === 'signature' && tsType.type === 'function') {
217
+ return { name: 'func', funcSignature: tsTypeDump(tsType) };
169
218
  } else if (tsType.name === 'union') {
170
219
  if (tsType.raw) {
171
220
  // Props
@@ -194,6 +243,13 @@ class DocJSONBuilder {
194
243
  : propMeta.defaultValue.value.replace(/\n/g, ''),
195
244
  description: propMeta.description || 'FIX ME NO DESCRIPTION',
196
245
  };
246
+ if (
247
+ result.type &&
248
+ result.type.name === 'func' &&
249
+ result.type.funcSignature
250
+ ) {
251
+ result.description = `${result.description}\n*signature:*\`${result.type.funcSignature}\``;
252
+ }
197
253
  } else {
198
254
  if (propName) {
199
255
  result.name = propName;
@@ -8,7 +8,7 @@
8
8
  <%_ if (component.props && component.props.length) { _%>
9
9
  ## props
10
10
  | Prop | Type | Default | Required | Description |
11
- | ---- | :--: | :-----: | :------: | :----------: |
11
+ | ---- | :-- | :----- | :------ | :---------- |
12
12
  <%- propMarkdownTableRows(component) %>
13
13
  <%_ } _%>
14
14
 
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
-
3
- export interface PointAnnotationProps {
4
- coordinate: [number, number];
5
- anchor: {
6
- x: number;
7
- y: number;
8
- };
9
- }
10
-
11
- export default class PointAnnotation extends React.Component<PointAnnotationProps> {
12
- refresh(): void;
13
- }
@@ -1,217 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { requireNativeComponent, StyleSheet, Platform } from 'react-native';
4
-
5
- import { toJSONString, isFunction, viewPropTypes } from '../utils';
6
- import { makePoint } from '../utils/geoUtils';
7
-
8
- import NativeBridgeComponent from './NativeBridgeComponent';
9
-
10
- export const NATIVE_MODULE_NAME = 'RCTMGLPointAnnotation';
11
-
12
- const styles = StyleSheet.create({
13
- container: {
14
- alignItems: 'center',
15
- justifyContent: 'center',
16
- position: 'absolute',
17
- },
18
- });
19
-
20
- /**
21
- * PointAnnotation represents a one-dimensional shape located at a single geographical coordinate.
22
- *
23
- * Consider using ShapeSource and SymbolLayer instead, if you have many points and you have static images,
24
- * they'll offer much better performance.
25
- *
26
- * If you need interactive views please use MarkerView,
27
- * as with PointAnnotation on Android child views are rendered onto a bitmap for better performance.
28
- */
29
- class PointAnnotation extends NativeBridgeComponent(React.PureComponent) {
30
- static propTypes = {
31
- ...viewPropTypes,
32
-
33
- /**
34
- * A string that uniquely identifies the annotation
35
- */
36
- id: PropTypes.string.isRequired,
37
-
38
- /**
39
- * The string containing the annotation’s title. Note this is required to be set if you want to see a callout appear on iOS.
40
- */
41
- title: PropTypes.string,
42
-
43
- /**
44
- * The string containing the annotation’s snippet(subtitle). Not displayed in the default callout.
45
- */
46
- snippet: PropTypes.string,
47
-
48
- /**
49
- * Manually selects/deselects annotation
50
- * @type {[type]}
51
- */
52
- selected: PropTypes.bool,
53
-
54
- /**
55
- * Enable or disable dragging. Defaults to false.
56
- */
57
- draggable: PropTypes.bool,
58
-
59
- /**
60
- * The center point (specified as a map coordinate) of the annotation.
61
- */
62
- coordinate: PropTypes.arrayOf(PropTypes.number).isRequired,
63
-
64
- /**
65
- * Specifies the anchor being set on a particular point of the annotation.
66
- * The anchor point is specified in the continuous space [0.0, 1.0] x [0.0, 1.0],
67
- * where (0, 0) is the top-left corner of the image, and (1, 1) is the bottom-right corner.
68
- * Note this is only for custom annotations not the default pin view.
69
- * Defaults to the center of the view.
70
- */
71
- anchor: PropTypes.shape({
72
- /**
73
- * See anchor
74
- */
75
- x: PropTypes.number.isRequired,
76
- /**
77
- * See anchor
78
- */
79
- y: PropTypes.number.isRequired,
80
- }),
81
-
82
- /**
83
- * This callback is fired once this annotation is selected. Returns a Feature as the first param.
84
- */
85
- onSelected: PropTypes.func,
86
-
87
- /**
88
- * This callback is fired once this annotation is deselected.
89
- */
90
- onDeselected: PropTypes.func,
91
-
92
- /**
93
- * This callback is fired once this annotation has started being dragged.
94
- */
95
- onDragStart: PropTypes.func,
96
-
97
- /**
98
- * This callback is fired once this annotation has stopped being dragged.
99
- */
100
- onDragEnd: PropTypes.func,
101
-
102
- /**
103
- * This callback is fired while this annotation is being dragged.
104
- */
105
- onDrag: PropTypes.func,
106
- };
107
-
108
- static defaultProps = {
109
- anchor: { x: 0.5, y: 0.5 },
110
- draggable: false,
111
- };
112
-
113
- constructor(props) {
114
- super(props, NATIVE_MODULE_NAME);
115
- this._onSelected = this._onSelected.bind(this);
116
- this._onDeselected = this._onDeselected.bind(this);
117
- this._onDragStart = this._onDragStart.bind(this);
118
- this._onDrag = this._onDrag.bind(this);
119
- this._onDragEnd = this._onDragEnd.bind(this);
120
- }
121
-
122
- _onSelected(e) {
123
- if (isFunction(this.props.onSelected)) {
124
- this.props.onSelected(e.nativeEvent.payload);
125
- }
126
- }
127
-
128
- _onDeselected(e) {
129
- if (isFunction(this.props.onDeselected)) {
130
- this.props.onDeselected(e.nativeEvent.payload);
131
- }
132
- }
133
-
134
- _onDragStart(e) {
135
- if (isFunction(this.props.onDragStart)) {
136
- this.props.onDragStart(e.nativeEvent.payload);
137
- }
138
- }
139
-
140
- _onDrag(e) {
141
- if (isFunction(this.props.onDrag)) {
142
- this.props.onDrag(e.nativeEvent.payload);
143
- }
144
- }
145
-
146
- _onDragEnd(e) {
147
- if (isFunction(this.props.onDragEnd)) {
148
- this.props.onDragEnd(e.nativeEvent.payload);
149
- }
150
- }
151
-
152
- _getCoordinate() {
153
- if (!this.props.coordinate) {
154
- return undefined;
155
- }
156
- return toJSONString(makePoint(this.props.coordinate));
157
- }
158
-
159
- /**
160
- * On v10 and pre v10 android point annotation is rendered offscreen with a canvas into an image.
161
- * To rerender the image from the current state of the view call refresh.
162
- * Call this for example from Image#onLoad.
163
- */
164
- refresh() {
165
- if (Platform.OS === 'android') {
166
- this._runNativeCommand('refresh', this._nativeRef, []);
167
- } else {
168
- this._runNativeCommand('refresh', this._nativeRef, []);
169
- }
170
- }
171
-
172
- _setNativeRef(nativeRef) {
173
- this._nativeRef = nativeRef;
174
- super._runPendingNativeCommands(nativeRef);
175
- }
176
-
177
- render() {
178
- const props = {
179
- ...this.props,
180
- ref: (nativeRef) => this._setNativeRef(nativeRef),
181
- id: this.props.id,
182
- title: this.props.title,
183
- snippet: this.props.snippet,
184
- anchor: this.props.anchor,
185
- selected: this.props.selected,
186
- draggable: this.props.draggable,
187
- style: [this.props.style, styles.container],
188
- onMapboxPointAnnotationSelected: this._onSelected,
189
- onMapboxPointAnnotationDeselected: this._onDeselected,
190
- onMapboxPointAnnotationDragStart: this._onDragStart,
191
- onMapboxPointAnnotationDrag: this._onDrag,
192
- onMapboxPointAnnotationDragEnd: this._onDragEnd,
193
- coordinate: this._getCoordinate(),
194
- };
195
- return (
196
- <RCTMGLPointAnnotation {...props}>
197
- {this.props.children}
198
- </RCTMGLPointAnnotation>
199
- );
200
- }
201
- }
202
-
203
- const RCTMGLPointAnnotation = requireNativeComponent(
204
- NATIVE_MODULE_NAME,
205
- PointAnnotation,
206
- {
207
- nativeOnly: {
208
- onMapboxPointAnnotationSelected: true,
209
- onMapboxPointAnnotationDeselected: true,
210
- onMapboxPointAnnotationDragStart: true,
211
- onMapboxPointAnnotationDrag: true,
212
- onMapboxPointAnnotationDragEnd: true,
213
- },
214
- },
215
- );
216
-
217
- export default PointAnnotation;