Geocoding control (place search box)
Get it from npm registry
View source code on GitHub
The geocoding control implements a complete place search in your map or other frontend application. This page explains how to implement it with MapTiler SDK JS.
Get started
For the most basic integration, see the code example Add place search to map.
If you’re using a JS framework like React or Svelte, get tailored instructions in these tutorials:
You can also go to GitHub or npm for integration details.
Configure search
To customize the geocoding control behavior for your needs, see these examples:
- Limit results by country
- Limit results by a bounding box
- Draw a custom search area
- Prioritize nearby results
- Search specific place types
- Set search language
The search control has many more powerful config options, including autocomplete and typing predictions or highlighting search results on the map. Check out the geocoding control API reference to see all options.
Advanced topics
The geocoding control can be used as an ES Module (ESM) or UMD (Universal Module Definition).
UMD global variables
When importing scripts from CDN using <script> tags, the library creates global variables according to this table:
| Script filename | UMD global variable name | Exports |
|---|---|---|
maptilersdk.umd.js |
maptilersdkMaptilerGeocoder |
class GeocodingControl, function createMapLibreGlMapController |
leaflet.umd.js |
leafletMaptilerGeocoder |
class GeocodingControl, function createLeafletMapController |
maplibregl.umd.js |
maplibreglMaptilerGeocoder |
class GeocodingControl, function createMapLibreGlMapController |
openlayers.umd.js |
openlayersMaptilerGeocoder |
class GeocodingControl, function createOpenLayersMapController |
react.umd.js |
reactMaptilerGeocoder |
class GeocodingControl |
vanilla.umd.js |
maptilerGeocoder |
class GeocodingControl |
leaflet-controller.umd.js |
leafletMaptilerGeocodingController |
function createLeafletMapController |
maplibregl-controller.umd.js |
maplibreglMaptilerGeocodingController |
function createMapLibreGlMapController |
openlayers-controller.umd.js |
openlayersMaptilerGeocodingController |
function createOpenLayersMapController |
The variable is an object with properties representing library-exported variables, for example maplibreglMaptilerGeocoder.GeocodingControl.
Alternatively you can use different CDN, for example https://www.unpkg.com/@maptiler/geocoding-control@${version}/${Script filename}. Replace ${version} with the desired library version and ${Script filename} with the script filename from the table above.
POI icons and bundlers
POI icons are served from CDN by default. If you need to serve them from a different location when using a web application bundler (Webpack, Vite), you’ll need additional configuration.
Icons are bundled in the library at node_modules/@maptiler/geocoding-control/icons. You can either:
- Configure your bundler to handle the icons directory
- Use the
iconsBaseUrlconfiguration option to specify the icon location - Copy the icons to your
publicdirectory