Skip to main content

Polyline

The Polyline component draws a line connecting a sequence of geographic coordinates. Supports two styles: solid and dashed. Must be rendered as a child of <Map>.

Import

import { Polyline } from 'react-native-here-explore';
import type { PolylineProps } from 'react-native-here-explore';

Usage

Solid line

<Map mapScheme="NORMAL_DAY" geoCoordinates={{ latitude: 48.85, longitude: 2.35 }} zoomValue={12}>
<Polyline
lineType="SOLID"
geoPolyline={[
{ latitude: 48.85, longitude: 2.30 },
{ latitude: 48.85, longitude: 2.35 },
{ latitude: 48.87, longitude: 2.40 },
]}
lineColor="#1A73E8"
lineWidth={6}
outlineColor="#0D47A1"
outlineWidth={2}
/>
</Map>

Dashed line

<Polyline
lineType="DASH"
geoPolyline={[
{ latitude: 48.85, longitude: 2.30 },
{ latitude: 48.87, longitude: 2.40 },
]}
lineColor="#FF5722"
lineWidth={4}
gapLength={6}
lineLength={10}
gapColor="rgba(0,0,0,0)"
/>

Route visualization

<Polyline
lineType="SOLID"
geoPolyline={route.vertices}
lineColor="#00BCD4"
lineWidth={8}
lineWidthUnit="PIXELS"
capShape="ROUND"
/>

Props

Base props (both SOLID and DASH)

PropTypeRequiredDefaultDescription
geoPolylineGeoPolylineYesArray of coordinates. Minimum 2 points required
lineType'SOLID' | 'DASH'YesLine style
lineWidthnumberNo8.0Line thickness
lineWidthUnitLineWidthUnitNo'PIXELS'Unit for lineWidth
lineColorColorValueNo'white'Line color. Accepts named colors, hex, or rgba

Solid line props (lineType="SOLID")

PropTypeRequiredDefaultDescription
outlineWidthnumberNo8.0Width of the border drawn around the line
outlineColorColorValueNo'white'Color of the outline
capShapeLineCapNoStyle of line endpoints

Dashed line props (lineType="DASH")

PropTypeRequiredDefaultDescription
gapLengthnumberYesLength of the gap between dashes
lineLengthnumberNoLength of each dash
gapColorColorValueNoColor of the gap between dashes

LineWidthUnit

ValueDescription
'PIXELS'Screen pixels (default)
'DENSITY_INDEPENDENT_PIXELS'DIP/DP — scales with screen density
'METERS'Physical meters on the ground

LineCap

Controls the shape of the line endpoints (solid lines only).

ValueDescription
'ROUND'Rounded ends
'SQUARE'Square ends extending past the endpoint
'BUTT'Flat ends exactly at the endpoint

Color formats

All color props accept any React Native ColorValue:

"white"                   // named color
"#FF5722" // hex (6-digit)
"#FF5722FF" // hex with alpha (8-digit)
"rgba(255, 87, 34, 0.8)" // rgba