← Back to examples
API Reference — async-map-modal
Full parameter documentation for showMapModal(options) and helper functions.
Contents
showMapModal(options)
Opens the map modal. Returns Promise<{ lat, lng } | null> in single-select mode, Promise<Array<{ lat, lng }> | null> in multi-select mode.
Mode
Parameter Type Default Description
multiSelect
boolean
false
true = multiple points, list on the right, checkboxes, delete one/all. false = single point.
Example — single:
const result = await asyncMapModal.show({ leaflet: L });
// result: { lat: 39.93, lng: 32.85 } or null
Example — multiple:
const points = await asyncMapModal.show({ multiSelect: true , leaflet: L });
// points: [{ lat, lng }, ...] or null
Title and button labels
Parameter Type Default Mode Description
titlestringFrom locale both Modal title.
confirmTextstringFrom locale both Confirm button label (e.g. "Select", "OK").
cancelTextstringFrom locale both Cancel button label.
copyTextstringFrom locale both Copy coordinates button label.
deleteSelectedTextstringFrom locale multi "Delete selected" button label.
deleteAllTextstringFrom locale multi "Delete all" button label.
listTitlestringFrom locale multi Right-hand list section title (e.g. "Selected points").
fitBoundsTextstringFrom locale multi "Show all" (fit all points on map) button label.
asyncMapModal.show({
title: 'Select delivery address' ,
confirmText: 'Deliver here' ,
cancelText: 'Cancel' ,
copyText: 'Copy coordinates' ,
leaflet: L,
});
Map initial values
Parameter Type Default Description
initialCenter[number, number][38.7143, 35.5323]Map center on open [lat, lng].
initialZoomnumber13Initial zoom level (0–22, depends on tile maxZoom).
mapHeightstring'400px'CSS height of map container (e.g. '50vh', '300px').
asyncMapModal.show({
initialCenter: [41.0082, 28.9784],
initialZoom: 11,
mapHeight: '50vh' ,
leaflet: L,
});
Marker
Parameter Type Default Description
markerIconL.Icon | L.DivIconnullCustom marker icon. null = default Leaflet blue pin. Same icon in single and multi mode.
const customIcon = L.divIcon({
className: 'my-marker' ,
html: '<span class="pin"></span>' ,
iconSize: [24, 24],
iconAnchor: [12, 24],
});
asyncMapModal.show({ markerIcon: customIcon, leaflet: L });
Multi-select only
Parameter Type Default Description
initialPointsArray<{lat,lng}|[number,number]>[]Points to show in the list when modal opens. User can add/remove; "OK" returns current list.
maxPointsnumber | nullnullMax number of points. When set, no new point is added above this limit. null = unlimited.
asyncMapModal.show({
multiSelect: true ,
initialPoints: [
{ lat: 39.9255, lng: 32.8663 },
[41.0082, 28.9784],
],
maxPoints: 10,
leaflet: L,
});
Selection bounds
Restrict selectable coordinates. Two options:
Parameter Type Default Description
bounds[[number, number], [number, number]]— [[south, west], [north, east]] — only clicks/paste inside this area are accepted.
minLat, maxLatnumber— Latitude min/max.
minLng, maxLngnumber— Longitude min/max.
asyncMapModal.show({
bounds: [[39.5, 32.0], [42.0, 35.0]],
initialCenter: [40.5, 33.5],
leaflet: L,
});
Tile layer
Parameter Type Default Description
tileLayerUrlstringOpenStreetMap Tile URL template (e.g. https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png).
tileLayerAttributionstring© OSM Attribution text shown below map.
tileLayerMaxZoomnumber18Max zoom for the layer.
asyncMapModal.show({
tileLayerUrl: 'https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png' ,
tileLayerAttribution: '© CARTO' ,
tileLayerMaxZoom: 19,
leaflet: L,
});
Language and theme
Parameter Type Default Description
languagestringgetConfig() or 'tr' UI language: 'tr', 'en', 'de', 'es', 'fr'. All strings in-package.
darkMode'light' | 'dark' | 'auto'getConfig() or 'light' Modal theme. 'auto' = system preference (prefers-color-scheme: dark).
asyncMapModal.show({
language: 'en' ,
darkMode: 'dark' ,
leaflet: L,
});
Leaflet reference
Parameter Type Default Description
leafletobjectwindow.LLeaflet library object. Required when L is not global (e.g. in ESM).
import L from 'leaflet' ;
const result = await asyncMapModal.show({ leaflet: L });
init(options)
Sets project-wide default language and theme. Subsequent showMapModal calls merge these with their options; per-call language / darkMode take precedence.
Parameter Type Description
languagestringDefault language: 'tr', 'en', 'de', 'es', 'fr'.
darkMode'light' | 'dark' | 'auto'Default theme.
asyncMapModal.init({
language: 'en' ,
darkMode: 'auto' ,
});
getConfig()
Returns current project defaults (copy). Use init, setTheme, or setLanguage to change them.
Returns: { language: string | undefined, darkMode: string | undefined }
const config = asyncMapModal.getConfig();
console.log(config.language, config.darkMode);
setTheme(theme)
Sets default theme. Used by showMapModal when options.darkMode is not provided.
Parameter Type Description
theme'light' | 'dark' | 'auto'Theme to use.
asyncMapModal.setTheme('dark' );
setLanguage(lang)
Sets default language code.
Parameter Type Description
langstring'tr', 'en', 'de', 'es', 'fr'.
asyncMapModal.setLanguage('en' );
Parameter summary table
Parameter Type Default Mode
multiSelect boolean false —
title string (locale) both
initialCenter [number, number] [38.7143, 35.5323] both
initialZoom number 13 both
confirmText string (locale) both
cancelText string (locale) both
mapHeight string '400px' both
markerIcon L.Icon | L.DivIcon null both
copyText string (locale) both
deleteSelectedText string (locale) multi
deleteAllText string (locale) multi
listTitle string (locale) multi
fitBoundsText string (locale) multi
initialPoints Array [] multi
maxPoints number | null null multi
bounds [[s,w],[n,e]] — both
minLat, maxLat, minLng, maxLng number — both
tileLayerUrl string OSM both
tileLayerAttribution string OSM both
tileLayerMaxZoom number 18 both
language string tr / getConfig() both
darkMode 'light'|'dark'|'auto' light / getConfig() both
leaflet object window.L both
API documentation for the async-map-modal package.