GeoJSON Source
A geojson source provides vector data from a GeoJSON document, either fetched from a URL or given inline. Render it with a vector layer.
Properties
Section titled “Properties”| Property | Type | Default | Description |
|---|---|---|---|
type | "geojson" | (required) | Source type. |
url | string | — | URL to fetch the GeoJSON from. Mutually exclusive with data; takes precedence when both are given. |
data | FeatureCollection | Feature | Geometry | — | Inline GeoJSON document. Used when url is not given. |
crs | string | — | Coordinate reference system of the data. |
tiled | boolean | false | Build a tiled spatial index (GeoJSON-VT) for large datasets. |
Examples
Section titled “Examples”import ThreeView from "@navaramap/three";
// From a URLconst roads = view.addSource({ type: "geojson", url: "https://example.com/roads.geojson",});view.addLayer({ type: "vector", source: roads, polyline: { color: 0xffffff } });
// Inlineconst pins = view.addSource({ type: "geojson", data: { type: "FeatureCollection", features: [ { type: "Feature", geometry: { type: "Point", coordinates: [139.767, 35.681] }, properties: {} }, ], },});view.addLayer({ type: "vector", source: pins, point: { color: 0xff0000, size: 8 } });Related Resources
Section titled “Related Resources”- About Source
- Vector Layer —
point,polyline,polygon,text,billboard