Skip to content

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.

PropertyTypeDefaultDescription
type"geojson"(required)Source type.
urlstringURL to fetch the GeoJSON from. Mutually exclusive with data; takes precedence when both are given.
dataFeatureCollection | Feature | GeometryInline GeoJSON document. Used when url is not given.
crsstringCoordinate reference system of the data.
tiledbooleanfalseBuild a tiled spatial index (GeoJSON-VT) for large datasets.
import ThreeView from "@navaramap/three";
// From a URL
const roads = view.addSource({
type: "geojson",
url: "https://example.com/roads.geojson",
});
view.addLayer({ type: "vector", source: roads, polyline: { color: 0xffffff } });
// Inline
const 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 } });