Add the geocoder to a container. The container can be either a Map
, an HTMLElement
or a CSS selector string.
If the container is a Map
, this function will behave identically to Map.addControl(geocoder)
.
If the container is an instance of HTMLElement
, then the geocoder will be appended as a child of that HTMLElement
.
If the container is a CSS selector string, the geocoder will be appended to the element returned from the query.
This function will throw an error if the container is none of the above.
It will also throw an error if the referenced HTML element cannot be found in the document.body
.
For example, if the HTML body contains the element <div id='geocoder-container'></div>
, the following script will append the geocoder to #geocoder-container
:
A reference to the container to which to add the geocoder
Clear and then focus the input.
Optional
ev: Eventthe event that triggered the clear, if available
Get the bounding box used by the plugin
the bounding box, if any
Get a list of the countries to limit search results to
a comma separated list of countries to limit to, if any
Get the filter function used by the plugin
the filter function
Get the parameters used to fly to the selected response, if any
The flyTo
option
Get the geocoding endpoint the plugin is currently set to
the geocoding API
Get the language to use in UI elements and when making search requests
The language(s) used by the plugin, if any
Get the limit value for the number of results to display used by the plugin
The limit value for the number of results to display used by the plugin
Get the minimum number of characters typed to trigger results used in the plugin
The minimum length in characters before a search is triggered
Get the value of the placeholder string
The input element's placeholder value
Get proximity
The geocoder proximity
Get the function used to render the results dropdown
the render function
Get a list of the types to limit search results to
a comma separated list of types to limit to
Get the zoom level the map will move to when there is no bounding box on the selected result
the map zoom
Remove an event
Event name.
Function that should unsubscribe to the event emitted.
Subscribe to events that happen within the plugin.
name of event. Available events and the data passed into their respective event objects are:
Emitted when the input is cleared
{ query } Emitted when the geocoder is looking up a query
{ results } Fired when the geocoder returns a response
{ result } Fired when input is set
{ error } Error as string
function that's called when the event is emitted.
Optional
map: Map$1Subscribe to events that happen within the plugin only once.
Event name. Available events and the data passed into their respective event objects are:
Emitted when the input is cleared
{ query } Emitted when the geocoder is looking up a query
{ results } Fired when the geocoder returns a response
{ result } Fired when input is set
{ error } Error as string
a Promise that resolves when the event is emitted.
Set & query the input
location name or other search input
Set the bounding box to limit search results to
a bounding box given as an array in the format [minX, minY, maxX, maxY].
Set the countries to limit search results to
a comma separated list of countries to limit to
Set the filter function used by the plugin.
A function which accepts a CarmenGeojsonFeature to filter out results from the Geocoding API response before they are included in the suggestions list. Return true
to keep the item, false
otherwise.
Set the flyTo options
Set input
location name or other search input
Get the language to use in UI elements and when making search requests
Look first at the explicitly set options otherwise use the browser's language settings
Optional
language: stringSpecify the language to use for response text and query result weighting. Options are IETF language tags comprised of a mandatory ISO 639-1 language code and optionally one or more IETF subtags for country or script. More than one value can also be specified, separated by commas.
Set the limit value for the number of results to display used by the plugin
the number of search results to return
Set the minimum number of characters typed to trigger results used by the plugin
the minimum length in characters
Set the value of the input element's placeholder
Optional
placeholder: stringthe text to use as the input element's placeholder
Set proximity
The new options.proximity
value. This is a geographical point given as an object with latitude
and longitude
properties.
Set the render function used in the results dropdown
The function to use as a render function. This function accepts a single CarmenGeojsonFeature object as input and returns a string.
Set the types to limit search results to
a comma separated list of types to limit to
Set the zoom level
The zoom level that the map should animate to when a bbox
isn't found in the response. If a bbox
is found the map will fit to the bbox
.
this
A geocoder component that works with maplibre