From 56ab3a009fbc41392a019572917803d798a21579 Mon Sep 17 00:00:00 2001 From: Craig Weiss Date: Sat, 20 Aug 2022 19:45:34 -0700 Subject: [PATCH 1/3] Add support for polyline borders --- index.d.ts | 13 +++++++++++++ src/MapViewDirections.js | 8 +++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index b19991a..3e0a523 100644 --- a/index.d.ts +++ b/index.d.ts @@ -211,6 +211,19 @@ declare module "react-native-maps-directions" { * Default: "#000" */ strokeColor?: string; + /** + * @number + * The stroke border width to use for the path + * 0 indicates no border. + * Default: 0 + */ + strokeBorderWidth?: number; + /** + * @string + * The stroke border color to use for the path. + * Default: "#FFF" + */ + strokeBorderColor?: string; /** * @Array * The stroke colors to use for the path (iOS only). diff --git a/src/MapViewDirections.js b/src/MapViewDirections.js index 8e05906..1e9eeec 100644 --- a/src/MapViewDirections.js +++ b/src/MapViewDirections.js @@ -92,6 +92,9 @@ class MapViewDirections extends Component { precision = 'low', timePrecision = 'none', channel, + strokeWidth = 1, + strokeBorderWidth = 0, + strokeBorderColor = '#FFF', } = props; if (!apikey) { @@ -308,7 +311,10 @@ class MapViewDirections extends Component { } = this.props; return ( - + <> + {strokeBorderWidth > 0 && } + + ); } From 78843d332dbe457b41efbb6f968b1ef2076a3098 Mon Sep 17 00:00:00 2001 From: Craig Weiss Date: Sun, 28 Aug 2022 15:18:20 -0700 Subject: [PATCH 2/3] fix: was too lazy to test --- src/MapViewDirections.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/MapViewDirections.js b/src/MapViewDirections.js index 1e9eeec..2595a16 100644 --- a/src/MapViewDirections.js +++ b/src/MapViewDirections.js @@ -92,9 +92,6 @@ class MapViewDirections extends Component { precision = 'low', timePrecision = 'none', channel, - strokeWidth = 1, - strokeBorderWidth = 0, - strokeBorderColor = '#FFF', } = props; if (!apikey) { @@ -310,9 +307,17 @@ class MapViewDirections extends Component { ...props } = this.props; + const borderPolylineProps = { + ...props, + strokeWidth: this.strokeBorderWidth + this.strokeWidth, + strokeColor: this.strokeBorderColor, + }; + return ( <> - {strokeBorderWidth > 0 && } + {this.strokeBorderWidth > 0 && + + } ); @@ -358,6 +363,9 @@ MapViewDirections.propTypes = { precision: PropTypes.oneOf(['high', 'low']), timePrecision: PropTypes.oneOf(['now', 'none']), channel: PropTypes.string, + strokeWidth: PropTypes.number, + strokeBorderWidth: PropTypes.number, + strokeBorderColor: PropTypes.string, }; export default MapViewDirections; From 419d30a268a33ece35c1b1a9dcb42952c941d317 Mon Sep 17 00:00:00 2001 From: Craig Weiss Date: Sun, 28 Aug 2022 15:57:48 -0700 Subject: [PATCH 3/3] fix --- src/MapViewDirections.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/MapViewDirections.js b/src/MapViewDirections.js index 2595a16..00eecae 100644 --- a/src/MapViewDirections.js +++ b/src/MapViewDirections.js @@ -309,13 +309,13 @@ class MapViewDirections extends Component { const borderPolylineProps = { ...props, - strokeWidth: this.strokeBorderWidth + this.strokeWidth, - strokeColor: this.strokeBorderColor, + strokeWidth: props.strokeBorderWidth + props.strokeWidth, + strokeColor: props.strokeBorderColor, }; return ( <> - {this.strokeBorderWidth > 0 && + {props.strokeBorderWidth && }