Skip to content

utils/geojson

Type Aliases

LngLat

type LngLat = [number, number];

Defined in: utils/geojson.ts:7

Small typed builders for the GeoJSON features the map renderers and drawing managers construct inline all over the codebase. Coordinates follow the GeoJSON convention: [lng, lat].

Functions

pointFeature()

function pointFeature(
   coordinates, 
   properties?, 
id?): Feature<Point>;

Defined in: utils/geojson.ts:9

Parameters

coordinates

LngLat

properties?

GeoJsonProperties = {}

id?

string | number

Returns

Feature\<Point>


lineStringFeature()

function lineStringFeature(coordinates, properties?): Feature<LineString>;

Defined in: utils/geojson.ts:22

Parameters

coordinates

LngLat[]

properties?

GeoJsonProperties = {}

Returns

Feature\<LineString>


polygonFeature()

function polygonFeature(ring, properties?): Feature<Polygon>;

Defined in: utils/geojson.ts:37

Build a polygon feature from a single outer ring. The ring is closed automatically (first point appended) unless it already is.

Parameters

ring

LngLat[]

properties?

GeoJsonProperties = {}

Returns

Feature\<Polygon>


featureCollection()

function featureCollection<G>(features?): FeatureCollection<G>;

Defined in: utils/geojson.ts:49

Type Parameters

G

G extends Geometry

Parameters

features?

Feature\<G, GeoJsonProperties>[] = []

Returns

FeatureCollection\<G>


toLngLatCoords()

function toLngLatCoords(points): LngLat[];

Defined in: utils/geojson.ts:56

Convert {lat, lng} points (drawing managers' format) to [lng, lat].

Parameters

points

object[]

Returns

LngLat[]