Search features by coordinates using the geocoding control

Activate the enableReverse option during geocoding control initialization to support coordinate-based searches.

Setting this option to "always" lets you locate features using names, addresses, and coordinate pairs. For example typing 41.874836, -87.628261 in the search box will display items that match those coordinates, addresses, regions, states, etc.

Geocoding (forward geocoding and reverse geocoding) is a technique for place identification - either by name or coordinates. See the Geocoding page for more details.

Click on the map or type a coordinate in the search box to search for addresses

NPM module setup


npm install --save @maptiler/sdk @maptiler/geocoding-control
import { Map, MapStyle, config } from '@maptiler/sdk';
import '@maptiler/sdk/dist/maptiler-sdk.css';
import { GeocodingControl } from '@maptiler/geocoding-control/maptilersdk';

config.apiKey = 'YOUR_MAPTILER_API_KEY_HERE';

const map = new Map({
  container: 'map', // container id
  style: MapStyle.STREETS.LIGHT,
  geolocate: true
});

//set geocoding control search by coodinates (reverse geocoding)
const gc = new GeocodingControl({
  enableReverse: "always",
});

map.addControl(gc, 'top-left');

Learn more

Check the MapTiler Geocoding control API reference for all search options. For example specifying the language of the results, etc.

Do you want to see how the geocoder component is made? Check the MapTiler Geocoding control repository. You can also use it as inspiration to create your component.

Discover the process of integrating the geocoding control feature into your React (Geocoding React component repository) or Svelte (Geocoding Svelte component) applications. Additionally, you have the option to use the VanillaJS version to customize it for any of your applications.

Are you currently using a different map library? No worries! Learn how to incorporate the geocoding control functionality with Leaflet (Leaflet Geocoding control), OpenLayers (OpenLayers Geocoding control), or MapLibre GL JS (MapLibre GL JS Geocoding control).

How to search places by coordinates (reverse geocoding)

Reverse geocoding

Tutorials

Search places by coordinates using reverse geocoding.

Customize API request from geocoding control

Customize API request (geocoding control)

Examples

Modify geocoding URLs before fetching using the adjustUrl option.

Geocoding: Show place search results

Geocoding API

Tutorials

Search for places using the MapTiler Geocoding API.

Geocoding search results to specified country(ies)

Geocoding search results to specified country(ies)

Examples

Limit geocoding control search results to specific countries.

Was this helpful?