Class MaptilerGeocoderElement
Hierarchy
- LitElement
- MaptilerGeocoderElement
Implements
Index
Other
rendering
updates
Other
constructor
Returns MaptilerGeocoderElement
OptionaladjustUrl
Type Declaration
- (url: URL): void
Parameters
- url: URL
URL parameter that can be modified.
Default: Empty function.
Returns void
- url: URL
OptionalapiKey
MapTiler API key.
OptionalapiUrl
Geocoding API URL.
Default: MapTiler Geocoding API URL.
Optionalbbox
Bounding box in the format [minX, minY, maxX, maxY] to limit search results.
Default: undefined.
OptionalclearButtonTitle
Title of the clear button.
Default: "clear".
clearListOnPick
Clears the result list after picking an item. Prevents redisplaying the list when the input box is focused.
Default: false.
clearOnBlur
Clears the input value when it loses focus.
Default: false.
collapsed
Collapses the geocoder control until hovered or focused.
Default: false.
Optionalcountry
Limits search to the specified country or countries.
Default: undefined (all countries).
OptionaldebounceSearch
Time delay (in milliseconds) before querying the server after typing in the input box. Useful for reducing the number of API calls.
Default: 200.
OptionalenableReverse
Enables reverse geocoding:
"button": Enables reverse geocoding button."always": Reverse geocoding is always active.
Default: "never".
OptionalerrorMessage
Custom error message.
Default: "Something went wrong…".
excludeTypes
Includes all available types except those listed in the types option.
See reverseGeocodingExcludeTypes for reverse geocoding exclusion.
Default: false.
exhaustiveReverseGeocoding
Uses the limit option value for reverse geocoding even if the types option has multiple elements.
Works only if enabled on the server.
Default: false.
fetchFullGeometryOnPick
Enables fetching the full geometry (polygon etc.) instead of just a point on a picked feature.
Default: false.
OptionalfetchParameters
Additional parameters for fetch requests.
Default: undefined.
Optionalfilter
Callback function to filter results from the Geocoding API response.
The function should return true to keep an item, or false to exclude it.
Default: A function that always returns true.
OptionalfuzzyMatch
Enables fuzzy search.
Default: true.
OptionaliconsBaseUrl
Base URL for POI icons.
Default: "https://cdn.maptiler.com/maptiler-geocoding-control/v${version}/icons/"
keepListOpen
Keeps the result list open even if the control is unfocused.
Default: false.
Optionallanguage
Language for response text and query weighting.
Accepts IETF language tags.
Set to null or an empty string to disable language-specific searching.
Default: undefined (uses the browser's language settings).
Optionallimit
Maximum number of results to display.
See reverseGeocodingLimit for reverse geocoding limits.
Default: 5.
OptionalminLength
Minimum number of characters required to start a search.
Default: 2.
OptionalnoResultsMessage
Custom message for when no results are found.
Default:
"Oops! Looks like you're trying to predict something that's not quite right.We can't seem to find what you're looking for. Maybe try double-checking your spelling or try a different search term.Keep on typing - we'll do our best to get you where you need to go!"
openListOnTop
Opens the result list above the query input instead of below. Used when mounted at the bottom of a map.
Default: false.
Optionalplaceholder
Custom placeholder for the input box.
Default: "Search".
Optionalproximity
Prioritizes search results closer to a proximity point.
The first matching rule in the array is used.
Set to null to disable proximity.
Default: [ { type: "server-geolocation" } ].
reverseActive
Activates reverse geocoding.
Default: false.
OptionalreverseButtonTitle
Title of the reverse geocoding toggle button.
Default: "toggle reverse geocoding".
OptionalreverseGeocodingExcludeTypes
Excludes types for reverse geocoding.
Default: Same as excludeTypes.
OptionalreverseGeocodingLimit
Limits results for reverse geocoding. Applied only if value is 1 or effective types contain a single value.
See also reverseGeocodingTypes option.
Default: The value of the limit option if set. If effective types contain a single value, the default is 1. In all other cases, this option is not used.
OptionalreverseGeocodingTypes
Specifies types for reverse geocoding.
If effective types are multiple values, the limit/reverseGeocodingLimit option is ignored.
See also reverseGeocodingLimit option.
Default: Same as types.
OptionalselectFirst
Automatically selects the first feature in the result list.
Default: true.
OptionalshowPlaceType
Indicates when to show place/POI types in the dropdown:
"never": Hide the type."always": Always show the type."if-needed": Show the type only if it cannot be determined from the icon.
Default: "if-needed".
OptionalshowResultsWhileTyping
Displays results while typing:
false: Search occurs only on pressing the Enter key.true: Search begins when the input meets theminLengthrequirement.
Default: true.
Optionaltypes
Types to query, either as an array or [minZoom, maxZoom, type] format.
minZoom is inclusive, maxZoom is exclusive, and either can be null or undefined for unbounded values.
See reverseGeocodingTypes option for reverse geocoding types.
Default: undefined (uses server default feature types).
Optionalworldview
Some of the geographical boundaries and names are disputed. When worldview option is selected, the Geocoding API responses will be aligned with the borders and names recognized by the selected country. This affects filtering by country, the context returned with the given feature and also some of the labels (e.g., Gulf of Mexico vs. Gulf of America).
Available options:
"ch": Use the worldview of Switzerland"us": Use the worldview of US"auto": Automatically determine the worldview by the location of the clientundefined: Do not use any particular worldview (disputed areas are returned without country information, countries with disputed borders are returned without full geometry)
Default: undefined (no worldview).
addEventListener
- addEventListener<E extends keyof MaptilerGeocoderEventNameMap>(
type: E,
listener: (
this: HTMLElement,
e: MaptilerGeocoderEventNameMap[E],
) => unknown,
options?: boolean | AddEventListenerOptions,
): voidType Parameters
- E extends keyof MaptilerGeocoderEventNameMap
Parameters
- type: E
- listener: (this: HTMLElement, e: MaptilerGeocoderEventNameMap[E]) => unknown
Optionaloptions: boolean | AddEventListenerOptions
Returns void
blur
Blur the search input box.
Returns void
clearList
Clear search result list.
Returns void
focus
removeEventListener
- removeEventListener<E extends keyof MaptilerGeocoderEventNameMap>(
type: E,
listener: (
this: HTMLElement,
e: MaptilerGeocoderEventNameMap[E],
) => unknown,
options?: boolean | EventListenerOptions,
): voidType Parameters
- E extends keyof MaptilerGeocoderEventNameMap
Parameters
- type: E
- listener: (this: HTMLElement, e: MaptilerGeocoderEventNameMap[E]) => unknown
Optionaloptions: boolean | EventListenerOptions
Returns void
setOptions
Set the options of this instance.
Parameters
- options: Partial<MaptilerGeocoderOptions>
options to set
Returns void
- options: Partial<MaptilerGeocoderOptions>
setQuery
Set the content of search input box.
Parameters
- value: string
text to set
Returns void
- value: string
submitQuery
Set the content of search input box and immediately submit it.
Parameters
- value: string
text to set and submit
Returns void
- value: string
rendering
render
Invoked on each update to perform rendering tasks. This method may return any value renderable by lit-html's
ChildPart- typically aTemplateResult. Setting properties inside this method will not trigger the element to update.Returns TemplateResult<1>
updates
willUpdate
Invoked before
update()to compute values needed during the update.Implement
willUpdateto compute property values that depend on other properties and are used in the rest of the update process.willUpdate(changedProperties) { // only need to check changed properties for an expensive computation. if (changedProperties.has('firstName') || changedProperties.has('lastName')) { this.sha = computeSHA(`${this.firstName} ${this.lastName}`); }}render() { return html`SHA: ${this.sha}`;}Parameters
- changedProperties: Map<string, unknown>
Returns void
Callback function to adjust the geocoding URL before fetching.