Skip to content
Vue Neshan MapsDeveloper documentation

Markers & popups

Add stable marker IDs, text popups and persistent dragging.

1 min readVue 3 / Nuxt 4Live example included
On this pageMarkers
Interactive exampleMapLibre

Run on a real Neshan map

Bring a domain-allowed web key. Sample geometry; real basemap.

Allow sajadjanat.github.io. Your key stays in memory and is excluded from copied code.

Markers#

Give every marker a unique, stable id. Replace or update its position to move it; remove it from the array to remove it from the map. popup is plain text, and MapLibre tooltip becomes a DOM title. Clicking a marker emits marker-click; dragging emits marker-dragend(marker, coordinates).

The complete example's saveMarker persists drag results in application state. Without that update, a subsequent render can put the marker back at its old controlled position. Use MapLibreMarker for MapLibre and MapMarker for Leaflet: their native options are different.

ts
markers.value = [...markers.value, {
  id: 'new-place', position: [...center.value], popup: 'New place',
}]
markers.value = markers.value.filter(marker => marker.id !== 'new-place')

MapLibre accepts an HTMLElement through element for a custom marker. Create and sanitize that DOM yourself; do not pass untrusted HTML. Default markers need no custom DOM. openPopup(id) opens the popup of an existing MapLibre marker.

Independent community library. Map services and attribution belong to Neshan and OpenStreetMap. · Sajad Janat · MIT