diff --git a/docs/MapView.md b/docs/MapView.md index bfeb02b47..9990723d2 100644 --- a/docs/MapView.md +++ b/docs/MapView.md @@ -26,6 +26,7 @@ MapView backed by Mapbox Native GL | compassPosition | `custom` | `none` | `false` | [`mapbox` (v10) implementation only] Adds compass offset, e.g. `{top: 8, left: 8}` will put the compass in top-left corner of the map | | compassViewPosition | `number` | `none` | `false` | Change corner of map the compass starts at. 0: TopLeft, 1: TopRight, 2: BottomLeft, 3: BottomRight | | compassViewMargins | `object` | `none` | `false` | Add margins to the compass with x and y values | +| compassImage | `string` | `none` | `false` | [iOS, `mapbox` (v10) implementation only] A string referencing an image key. Requires an `Images` component. | | scaleBarEnabled | `bool` | `true` | `false` | [`mapbox` (v10) implementation only] Enable/Disable the scale bar from appearing on the map | | scaleBarPosition | `custom` | `none` | `false` | [`mapbox` (v10) implementation only] Adds scale bar offset, e.g. `{top: 8, left: 8}` will put the scale bar in top-left corner of the map | | surfaceView | `bool` | `false` | `false` | [Android only] Enable/Disable use of GLSurfaceView instead of TextureView. | diff --git a/docs/docs.json b/docs/docs.json index 66b7c86cc..70bc89ae6 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -3028,6 +3028,13 @@ "default": "none", "description": "Add margins to the compass with x and y values" }, + { + "name": "compassImage", + "required": false, + "type": "string", + "default": "none", + "description": "[iOS, `mapbox` (v10) implementation only] A string referencing an image key. Requires an `Images` component." + }, { "name": "scaleBarEnabled", "required": false, diff --git a/example/src/assets/compass1.png b/example/src/assets/compass1.png new file mode 100644 index 000000000..a29dd3b1f Binary files /dev/null and b/example/src/assets/compass1.png differ diff --git a/example/src/assets/compass2.png b/example/src/assets/compass2.png new file mode 100644 index 000000000..42ab102ff Binary files /dev/null and b/example/src/assets/compass2.png differ diff --git a/example/src/examples/Map/Ornaments.tsx b/example/src/examples/Map/Ornaments.tsx index 2c654aa4f..193482498 100755 --- a/example/src/examples/Map/Ornaments.tsx +++ b/example/src/examples/Map/Ornaments.tsx @@ -1,10 +1,18 @@ import React, { FC, useState } from 'react'; import MapboxGL from '@rnmapbox/maps'; import { Button, StyleSheet, Text } from 'react-native'; +import { Divider } from '@rneui/base'; import sheet from '../../styles/sheet'; import Page from '../common/Page'; import Bubble from '../common/Bubble'; +import { Images } from '../../../../javascript'; + +type CompassImage = 'compass1' | 'compass2'; +const images: Record = { + compass1: require('../../assets/compass1.png'), + compass2: require('../../assets/compass2.png'), +}; enum OrnamentType { Logo = 'logo', @@ -27,12 +35,6 @@ const POSITIONS = { [OrnamentPosition.BottomLeft]: { bottom: 8, left: 8 }, }; -const styles = StyleSheet.create({ - bubble: { - marginBottom: 96, - }, -}); - type OrnamentButtonsProps = { ornamentType: OrnamentType; visibility: Record; @@ -75,6 +77,11 @@ const ShowMap: FC = (props) => { [OrnamentType.ScaleBar]: OrnamentPosition.TopLeft, }); + const [compassImage, setCompassImage] = useState(); + const [compassFadeWhenNorth, setCompassFadeWhenNorth] = useState< + boolean | undefined + >(undefined); + const handlePressVisibility = (ornamentType: OrnamentType): void => { setVisibility((prevState) => { let newValue; @@ -119,9 +126,12 @@ const ShowMap: FC = (props) => { attributionPosition={POSITIONS[position[OrnamentType.Attribution]]} compassEnabled={visibility[OrnamentType.Compass]} compassPosition={POSITIONS[position[OrnamentType.Compass]]} + compassImage={compassImage} + compassFadeWhenNorth={compassFadeWhenNorth} scaleBarEnabled={visibility[OrnamentType.ScaleBar]} scaleBarPosition={POSITIONS[position[OrnamentType.ScaleBar]]} > + @@ -135,6 +145,8 @@ const ShowMap: FC = (props) => { onPressPosition={handlePressPosition} /> + + Attribution = (props) => { onPressPosition={handlePressPosition} /> + + Compass = (props) => { onPressVisibility={handlePressVisibility} onPressPosition={handlePressPosition} /> +