GeoJSON
Style point, line and polygon features with native source options.
On this page
GeoJSONInteractive exampleMapLibre
GeoJSON#
GeoJSON is longitude first, including when used with the Leaflet component. The optional MapLibre geojsonLayers array controls native rendering; omit source because the component manages it. Without custom layers, the component supplies point/line/polygon styling.
import type { MapLibreOverlayLayer } from 'vue-neshan-maps'
const geojson = {
type: 'FeatureCollection' as const,
features: [{
type: 'Feature' as const,
properties: { name: 'Azadi Square' },
geometry: { type: 'Point' as const, coordinates: [51.338, 35.6997] },
}],
}
const geojsonLayers: MapLibreOverlayLayer[] = [{
id: 'places', type: 'circle',
paint: { 'circle-radius': 8, 'circle-color': '#087f8c',
'circle-stroke-color': '#ffffff', 'circle-stroke-width': 2 },
}]<NeshanMapLibre :api-key="webKey" :geojson="geojson" :geojson-layers="geojsonLayers" />geojsonOptions contains native GeoJSON source options on MapLibre and L.GeoJSONOptions on Leaflet. See the complete GeoJSON component for a runnable starting point.