Polyline
A line through several points, with dashes, labels and length measurement
import { Polyline, SphereMap } from "gistda-sphere-react";
<SphereMap center={{ lon: 100.55, lat: 13.75 }} style={{ height: 400 }} zoom={10}>
<Polyline
positions={[
{ lon: 100.4, lat: 13.7 },
{ lon: 100.5, lat: 13.8 },
{ lon: 100.6, lat: 13.7 },
{ lon: 100.7, lat: 13.8 },
]}
lineColor="blue"
lineWidth={4}
lineStyle="Dashed"
title="Route A"
/>
</SphereMap>The shorter samples below leave out <SphereMap>, but every overlay goes inside one.
Props
| Prop | Type | Description |
|---|---|---|
positions | Location[] | GeoJSON | Required. Points along the line (at least two). null entries break it into separate lines. A GeoJSON LineString or MultiLineString also works. |
Lines also take the shape props, such as lineColor, lineWidth, lineStyle, label, popupContent and the event callbacks.
Line styles
lineStyle takes "Solid", "Dashed", "Dot" or your own dash pattern:
import { Polyline } from "gistda-sphere-react";
<Polyline positions={path} lineStyle={[12, 4, 2, 4]} lineWidth={3} />Ref
| Method | Description |
|---|---|
getPolyline() | The underlying sphere.Polyline. |
getLength(language?) | Length in meters, or text such as "15.5 km" with a language. |
union(other) | A new line joining this one and another (not added to the map). |
getBound(), getCentroid(), getPivot() | Bounding box, center and label point. |
contains, intersects, within, distanceTo | Spatial tests. See Spatial analysis. |
rotate, shift, updateStyle, togglePopup, toGeoJSON | As for polygons. |