API reference for geometry utilities in 3DMapFi.
// Example: Creating a GeoJSON point const point = { type: "Feature", geometry: { type: "Point", coordinates: [105.85, 21.03] }, properties: {} }; // Add as a source map.addSource('point', { type: 'geojson', data: point });
// LineString const line = { type: "Feature", geometry: { type: "LineString", coordinates: [[105.85, 21.03], [105.9, 21.05]] }, properties: {} }; // Polygon const polygon = { type: "Feature", geometry: { type: "Polygon", coordinates: [[[105.8, 21.0], [105.9, 21.0], [105.9, 21.1], [105.8, 21.1], [105.8, 21.0]]] }, properties: {} };
import { distance } from '@3dmapfi/mapfi/geometry'; const d = distance([105.85, 21.03], [105.9, 21.05]); // Returns distance in meters
import { area } from '@3dmapfi/mapfi/geometry'; const a = area(polygon.geometry); // Returns area in square meters
import { buffer } from '@3dmapfi/mapfi/geometry'; const buffered = buffer(point.geometry, 100); // 100 meters buffer
const featureCollection = { type: "FeatureCollection", features: [point, line, polygon] }; map.addSource('features', { type: 'geojson', data: featureCollection });