MountayaMap
MountayaMap is a Mountaya map on MapLibre: a container and a client draw a base map from the layers manifest, and every layer added afterwards lands at its rank in LayerRank.
Builds the renderer in options.container and asks for the base map: the style given, or the catalogue terrain terrain names (the manifest's first by default).
new MountayaMap(options)
optionsMountayaMapOptions
MountayaMapOptions is everything new MountayaMap(...) takes.
Draws one itinerary, and frames it when fit asks. Replaces whichever was drawn before; null clears.
setItinerary(itinerary, options?)
itineraryRenderable
The itinerary's id, a specification already held, or null to clear.
optionsItineraryDrawOptions
default: {}
fit frames the itinerary once it is drawn, and signal withdraws the call.
Returns Promise<{ readonly drawn: boolean }>: Whether this call's itinerary is the one drawn.
drawnboolean
Draws one collection: every itinerary and zone it holds. Replaces whichever was drawn before; null clears.
setCollection(collection, options?)
collectionRenderable
The collection's id, a specification already held, or null to clear.
optionsCollectionDrawOptions
default: {}
fit frames the collection once it is drawn, and signal withdraws the call.
Returns Promise<{ readonly drawn: boolean }>: Whether this call's collection is the one drawn.
drawnboolean
clearItinerary, clearCollection and clearOverlay are the explicit clears, one per set.
clearItinerary()
Clears the collection drawn, as setCollection(null) does.
clearCollection()
Clears the classic overlay drawn, as setOverlay(null) does.
clearOverlay()
Toggles the aggregate itineraries layer: the itineraries of the credential's own scope, every one of its organization's under a key or a share token, and a signed-in person's personal space under their session. A map that follows another studio scope reads the layers catalog for it instead (setLayersOrganization).
setItineraries(on)
onboolean
Toggles the zones layer: the zones of the credential's own scope, as setItineraries reads it.
setZones(on)
onboolean
Switches the base map, by terrain slug.
setTerrain(slug)
slugstring | null
The terrain's slug as the manifest spells it, or null for the manifest's first terrain.
Swaps the base style for one you name, keeping everything drawn on top of it.
setStyle(style, options?)
styleStyleSpecification | string
options{ readonly transformStyle?: TransformStyleFunction | undefined }
default: {}
The slug of the catalogue terrain the base map is on, or null when it is on none: before the first terrain is found in the manifest, and under a style of the host's own (the style option, setStyle).
getTerrain()
Returns string | null: The terrain's slug as the manifest spells it, or null.
Switches the base map to the light or the dark variant of its catalogue terrain, apart from any colour scheme of the page around it.
setTerrainVariant(variant)
variantTerrainVariant
"light" or "dark".
The variant of a catalogue terrain the map draws: the variant of the terrain getTerrain names, on its way or shown, and otherwise the variant the next setTerrain draws in, which is the one the host asked for last. "light" unless the host asked for dark.
getTerrainVariant()
Returns TerrainVariant
Draws one classic overlay, by slug. Replaces whichever was drawn before; null clears.
setOverlay(slug)
slugstring | null
Draws one classic overlay you already hold, without reading the manifest.
setOverlaySpecification(overlay, options?)
overlayOverlay
optionsMountOptions
default: {}
Adds one enrichment overlay on top of whatever is already drawn.
addEnrichment(slug)
slugstring
Adds one enrichment overlay you already hold, without reading the manifest.
addEnrichmentSpecification(overlay, options?)
overlayOverlay
Its fields are listed under setOverlaySpecification.
optionsMountOptions
default: {}
Its fields are listed under setOverlaySpecification.
Removes one enrichment, by the slug addEnrichment was handed, and an addEnrichment of it still reading the manifest draws nothing. A slug not drawn changes nothing.
removeEnrichment(slug)
slugstring
Removes every enrichment, the ones still being found in the manifest included.
clearEnrichments()
The enrichment slugs currently drawn, in the order they were added.
getEnrichments()
Returns readonly string[]: The slugs, as one frozen array until the next displaychange.
Draws a specification you already hold, under a name of your choosing.
setSpecification(name, specification, options?)
namestring
specificationTileSpecification
optionsMountOptions
default: {}
Its fields are listed under setOverlaySpecification.
Removes the specification drawn under name. A name holding nothing is a no-op.
removeSpecification(name)
namestring
Removes every specification mounted by name, leaving this package's own slots drawn.
clearSpecifications()
The names currently drawn, in the order they were mounted.
getSpecifications()
Returns readonly string[]: The names, as one frozen array until the next displaychange.
Adds a layer of your own at a Mountaya rank, so it lands where that kind of layer belongs.
addLayer(layer, rank)
layerAddLayerObject
rankLayerRank
Removes a layer added by addLayer, and forgets its rank and visibility.
removeLayer(id)
idstring
Shows or hides Google's Street View coverage raster: where a panorama exists.
setStreetviewCoverage(visible, paint?)
visibleboolean
paintRasterPaint
default: {}
Draws routed directions between waypoints.
addDirections(input, options?)
inputDirectionsInput | DirectionsResult
optionsDrawOptions
default: {}
Returns Promise<AnalysisHandle<DirectionsResult>>
idAnalysisId
resultResult
Re-runs one directions result with patch merged onto the input it was drawn from. An empty patch restyles it from the result held, asking nothing. A member the patch or the options state as undefined leaves the one held.
editDirections(id, patch, options?)
idAnalysisId
patchPartial<DirectionsInput>
optionsDrawOptions
default: {}
Its fields are listed under addDirections.
Returns Promise<DirectionsResult>
routesArray<DirectionsRoute>
List of computed routes between the provided waypoints.
Removes one result, by the id addDirections answered, and cancels its query while it is in flight. An id not drawn changes nothing.
removeDirections(id)
idAnalysisId
Removes every directions result, and cancels the addDirections calls still waiting on their query: each rejects with the client's AbortError and draws nothing.
clearDirections()
Draws a set of suggested itineraries: the first solid, the rest dashed alternatives.
addSuggestions(input, options?)
inputSuggestionsInput | SuggestionsResult
optionsSuggestionDrawOptions
default: {}
Returns Promise<AnalysisHandle<SuggestionsResult>>
Its fields are listed under addDirections.
Re-runs or restyles one suggestion set.
editSuggestions(id, patch?, options?)
idAnalysisId
patchPartial<SuggestionsInput>
default: {}
Its fields are listed under editDirections.
optionsSuggestionDrawOptions
default: {}
Its fields are listed under addSuggestions.
Returns Promise<SuggestionsResult>
routesArray<SuggestionRoute>
Suggested route candidates: pinned seeds first, in the order given, then fresh candidates nearest the target distance first, or nearest the distance and ascent targets combined when ascent is positive. Can hold fewer routes than candidates.
Removes one result, by the id addSuggestions answered, and cancels its query while it is in flight. An id not drawn changes nothing.
removeSuggestions(id)
idAnalysisId
Removes every suggestion set, and cancels the addSuggestions calls still waiting on their query: each rejects with the client's AbortError and draws nothing.
clearSuggestions()
Draws reachability bands around one or more origins.
addIsochrones(input, options?)
inputIsochronesInput | IsochronesResult
optionsDrawOptions
default: {}
Its fields are listed under addDirections.
Returns Promise<AnalysisHandle<IsochronesResult>>
Its fields are listed under addDirections.
Re-runs one isochrone set with patch merged onto the input it was drawn from. An empty patch restyles it from the result held, asking nothing. A member the patch or the options state as undefined leaves the one held.
editIsochrones(id, patch, options?)
idAnalysisId
patchPartial<IsochronesInput>
Its fields are listed under editDirections.
optionsDrawOptions
default: {}
Its fields are listed under addDirections.
Returns Promise<IsochronesResult>
isochronesArray<Isochrone>
List of computed isochrones: one per location and range value, in the order the routing engine returns them. Read each one's value rather than relying on its position.
Removes one result, by the id addIsochrones answered, and cancels its query while it is in flight. An id not drawn changes nothing.
removeIsochrones(id)
idAnalysisId
Removes every isochrone set, and cancels the addIsochrones calls still waiting on their query: each rejects with the client's AbortError and draws nothing.
clearIsochrones()
Draws geocoding hits as labelled points.
addPlaces(input, options?)
inputGeocodeInput | GeocodeResult
optionsDrawOptions
default: {}
Its fields are listed under addDirections.
Returns Promise<AnalysisHandle<GeocodeResult>>
Its fields are listed under addDirections.
Re-runs one place search with patch merged onto the input it was drawn from. An empty patch restyles it from the result held, asking nothing. A member the patch or the options state as undefined leaves the one held.
editPlaces(id, patch, options?)
idAnalysisId
patchPartial<GeocodeInput>
Its fields are listed under editDirections.
optionsDrawOptions
default: {}
Its fields are listed under addDirections.
Returns Promise<GeocodeResult>
countScalars["Int"]["output"]
Number of places returned: the length of places, at most limit.
placesArray<Place>
List of named places ordered by relevance.
Removes one result, by the id addPlaces answered, and cancels its query while it is in flight. An id not drawn changes nothing.
removePlaces(id)
idAnalysisId
Removes every place search result, and cancels the addPlaces calls still waiting on their query: each rejects with the client's AbortError and draws nothing.
clearPlaces()
Draws a time-distance matrix as connectors between its locations.
addMatrix(input, options?)
inputMatrixInput
The matrix to solve: its locations, and the metrics to weigh each pair by.
optionsMatrixDrawOptions
default: {}
fit frames the matrix once it is drawn, and result is a result already held for input, drawn with no query.
Returns Promise<AnalysisHandle<MatrixResult>>: The id the matrix is drawn under, and its result: the client's answer, or options.result as it was handed over.
Its fields are listed under addDirections.
Re-runs one matrix with patch merged onto the input it was drawn from. An empty patch restyles it from the result held, asking nothing. A member the patch or the options state as undefined leaves the one held.
editMatrix(id, patch, options?)
idAnalysisId
patchPartial<MatrixInput>
Its fields are listed under editDirections.
optionsDrawOptions
default: {}
Its fields are listed under addDirections.
Returns Promise<MatrixResult>
distancesMaybe<Array<Array<Maybe<Scalars["Float"]["output"]>>>>
Distance grid in meters, one row per source and one column per destination: the routing engine's own figures, with no geometry returned to measure them against. Null inner values indicate unreachable pairs. Only present when DISTANCE metric is requested.
durationsMaybe<Array<Array<Maybe<Scalars["Float"]["output"]>>>>
Duration grid in seconds, one row per source and one column per destination. These are the routing engine's own estimates: they take no speed and do not use the terrain-aware model behind duration on directions, suggestions and analyzeGeometry, so they are not comparable with it. Null inner values indicate unreachable pairs. Only present when DURATION metric is requested.
Removes one result, by the id addMatrix answered, and cancels its query while it is in flight. An id not drawn changes nothing.
removeMatrix(id)
idAnalysisId
Removes every matrix, and cancels the addMatrix calls still waiting on their query: each rejects with the client's AbortError and draws nothing.
clearMatrix()
Draws the result of a points-of-interest query. One at a time, so this replaces.
setPointsOfInterest(input, options?)
inputPoisInput | PoisResult
optionsDrawOptions
default: {}
Its fields are listed under addDirections.
Returns Promise<PoisResult>
countScalars["Int"]["output"]
Number of POIs returned: the length of pois, at most limit.
poisArray<Poi>
List of POIs ordered by relevance. A buffered area does not reorder them by distance: read each one's distanceMeters.
Re-runs the POI query with patch merged onto the input it was drawn from. An empty patch restyles it from the result held, asking nothing. A member the patch or the options state as undefined leaves the one held.
editPointsOfInterest(patch, options?)
patchPartial<PoisInput>
Its fields are listed under editDirections.
optionsDrawOptions
default: {}
Its fields are listed under addDirections.
Returns Promise<PoisResult>
Its fields are listed under setPointsOfInterest.
Removes the points of interest drawn, and cancels their query while it is in flight.
clearPointsOfInterest()
Draws one unsaved geometry, an itinerary being planned. null clears.
setPreview(geometry, options?)
geometryGeometry | null
options{ readonly color?: string | undefined }
default: {}
Changes the preview's geometry, its colour, or both, keeping whatever is not named.
editPreview(patch)
patch{ readonly geometry?: Geometry | undefined; readonly color?: string | undefined }
Clears the unsaved geometry setPreview draws, as setPreview(null) does.
clearPreview()
Draws one highlighted feature, a search result. null clears.
setHighlight(feature, options?)
featureFeature | null
options{ readonly color?: string | undefined }
default: {}
Changes the highlighted feature, its colour, or both, keeping whatever is not named. A new colour reaches the drawn layers at once, with nothing rebuilt.
editHighlight(patch)
patch{ readonly feature?: Feature | undefined; readonly color?: string | undefined }
Clears the geometry setHighlight draws, as setHighlight(null) does.
clearHighlight()
Lights one stretch of what is already drawn: the leg a reader is pointing at.
setEmphasis(feature, options?)
featureFeature | null
options{ readonly color?: string | undefined }
default: {}
Clears the geometry setEmphasis draws, as setEmphasis(null) does.
clearEmphasis()
Pins a marker. An id already in use is replaced, so this is safe to call on every render.
addMarker(marker)
markerMarkerOptions
Changes one marker, keeping whatever the patch does not name.
editMarker(id, patch)
idstring
patchPartial<Omit<MarkerOptions, "id">>
Its fields are listed under editDirections.
Takes the marker pinned under id off the map and forgets what it was built from, so a later editMarker of that id throws. An id nothing is pinned under is a no-op.
removeMarker(id)
idstring
Removes every marker addMarker placed.
clearMarkers()
The camera as it stands: its centre, zoom, bearing and pitch.
getCamera()
Returns Camera
center[number, number]
zoomnumber
bearingnumber
pitchnumber
The zoom window the camera is held to: the lowest zoom it may reach and the highest.
getZoomLimits()
Returns { readonly max: number; readonly min: number }
maxnumber
minnumber
Moves the camera immediately, with no animation.
jumpTo(pose)
poseCameraPose
Moves the camera with the curved, zoom-out-and-in flight MapLibre calls a fly.
flyTo(pose)
poseCameraPose
Its fields are listed under jumpTo.
Moves the camera with a straight ease. The default for a programmatic move.
easeTo(pose)
poseCameraPose
Its fields are listed under jumpTo.
Moves the camera to frame a box, with the padding, zoom ceiling and duration options give. A member left out, or stated as undefined, takes MapLibre's own default.
fitBounds(bounds, options?)
boundsBoundingBox | LngLatBoundsLike
optionsFitBoundsOptions
default: {}
Eases the camera into the zoom range a specification paints over.
easeIntoZoomRange(target)
targetTileSpecification | ZoomRange
Eases the camera one zoom level in, within the zoom window the map holds.
zoomIn()
Eases the camera one zoom level out, within the zoom window the map holds.
zoomOut()
Rotates back to north, and levels the pitch: what a compass control means by reset.
resetNorth()
Sets the limits the camera may not leave: a zoom floor, a zoom ceiling and a pan lock. A member left out keeps its current limit, and a member of null releases it: a maxBounds of null lifts the lock, and a zoom limit of null goes back to the one a map is built with when it is given none, a floor of -2 and a ceiling of 22.
setConstraints(constraints)
constraintsCameraConstraints
Sets the language labels are drawn in.
setLanguage(language)
languagestring
The language labels are drawn in: the one setLanguage or the language option asked for, as the tiles carry it.
getLanguage()
Returns MapLanguage
The pixel a coordinate is drawn at, from the canvas's top-left corner. A destroyed map has no projection, and answers [NaN, NaN].
project(lngLat)
lngLat[number, number]
Returns [number, number]
The coordinate drawn at a pixel of the canvas. A destroyed map has no projection, and answers [NaN, NaN].
unproject(point)
point[number, number]
Returns [number, number]
The features this map drew at a screen point.
featuresAt(point)
point[number, number]
Returns Feature[]
The POI features rendered at a screen point.
poisAt(point)
point[number, number]
Returns Feature[]
The zone features rendered at a screen point.
zonesAt(point)
point[number, number]
Returns Feature[]
The itinerary features (routed lines and waypoints) rendered at a screen point.
itinerariesAt(point)
point[number, number]
Returns Feature[]
Ground elevation at a coordinate, in meters.
elevationAt(lngLat)
lngLat[number, number]
Returns Promise<number | null>
Full-text search across places, POIs, ways and the caller's own itineraries, collections and zones.
search(input, options?)
inputSearchInput
options{ readonly signal?: AbortSignal | undefined }
default: {}
Returns Promise<SearchResult>
collectionsMaybe<CollectionsResult>
Collections section. Null when the collections target was disabled or its branch errored.
errorsArray<SearchTargetError>
Graceful-degradation entries: one per target whose branch failed, or answered only in part because of a failure on Mountaya's side. Empty when every enabled branch succeeded.
itinerariesMaybe<ItinerariesResult>
Itineraries section. Null when the itineraries target was disabled or its branch errored.
languageLanguage
Language the place, POI and way names were returned in: the requested language when it is EN or FR, and EN otherwise, including when none was given.
placesMaybe<GeocodeResult>
Geocoded places section. Null when the places target was disabled or its branch errored.
poisMaybe<PoisResult>
Points-of-interest section. Null when the pois target was disabled or its branch errored.
queryScalars["String"]["output"]
Echo of the input query.
targetsSearchTargets
Echo of the per-target enable flags carried by the input.
waysMaybe<WaysResult>
Named-ways section. Null when the ways target was disabled or its branch errored.
zonesMaybe<ZonesResult>
Zones section. Null when the zones target was disabled or its branch errored.
locate(options?)
optionsGeolocationFixOptions
default: {}
Returns Promise<[number, number]>
setLayerVisibility shows or hides one layer of a drawn overlay, by its manifest id.
setLayerVisibility(layerId, visible)
layerIdstring
visibleboolean
isLayerVisible reports whether a layer is shown, that is not hidden by setLayerVisibility.
isLayerVisible(layerId)
layerIdstring
Returns boolean
The manifest concept keys currently drawn, in the order their layers were mounted.
drawnLayerKeys(rank?)
rankLayerRank
Returns readonly string[]: The keys, as one frozen array per rank until the next displaychange.
The ids of the drawn layers carrying one manifest key. Empty for a key nothing draws.
layerIdsForKey(key)
keystring
Returns readonly string[]: The ids, as one frozen array per key until the next displaychange.
Shows or hides every layer drawing one manifest concept.
setKeyVisibility(key, visible)
keystring
visibleboolean
Whether a concept is shown. A key drawing nothing reads as visible, matching isLayerVisible: nothing has been hidden, so nothing is.
isKeyVisible(key)
keystring
Returns boolean
Loads the layers manifest: every terrain, overlay and enrichment this credential may draw in the studio scope setLayersOrganization names. getLayers answers the one already loaded, with no read.
loadLayers()
Returns Promise<Layers>
elevationcomponents["schemas"]["Elevation"]
itinerariescomponents["schemas"]["Overlay"]
overlayscomponents["schemas"]["CategoryOverlays"][]
terrainscomponents["schemas"]["Terrain"][]
zonescomponents["schemas"]["Overlay"]
The layers manifest if it has already resolved, and undefined if it has not.
getLayers()
Returns Layers | undefined
Its fields are listed under loadLayers.
Names the studio scope the layers manifest is read for: an organization, sent as organization_id, or null for the read that names none.
setLayersOrganization(organizationId)
organizationIdstring | null
The organization whose scope the manifest is read for, or null for the read that names none.
Resolves once the map is ready to take sources and layers, and at once for a destroyed map, which is waiting on no style.
whenReady()
Subscribes to a map event. Returns the unsubscribe, so a caller never has to keep the handler around to detach it, the mistake that leaks listeners in every React codebase.
on<E>(event, handler)
eventE
The event, such as "moveend", "click" or "styleload".
handler(payload: MountayaMapEvents[E]) => void
Called with the event's payload.
Returns Unsubscribe: An unsubscribe that detaches this handler and no other.
Tears the map down. Idempotent: calling it twice is not an error.
destroy()
Subscribe with map.on(event, handler), which returns the function that unsubscribes.