Geocoding control (place search box)

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.

To customize the geocoding control behavior for your needs, see these examples:

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:

  1. Configure your bundler to handle the icons directory
  2. Use the iconsBaseUrl configuration option to specify the icon location
  3. Copy the icons to your public directory

Related examples