Leaflet GeoSearch
Edit page
IntroductionUsageLeaflet Control
Providers
AlgoliaBingEsriGeocode EarthGoogleHereLocationIQOpenCageOpenStreetMapPeliasCustom ProvidersGeoapifyGeoApiFrOptional parametersLegacyGoogle

GeoApiFr Provider

For more options and configurations, see the Geo Api FR.

import { GeoApiFrProvider } from 'leaflet-geosearch';
const provider = new GeoApiFrProvider();
// add to leaflet
import { GeoSearchControl } from 'leaflet-geosearch';
map.addControl(
new GeoSearchControl({
provider,
style: 'bar',
}),
);

Optional parameters

Geo Api FR supports a number of optional parameters. As the api requires those parameters to be added to the url, they can be added to the params key of the provider.

All options defined next to the params key, would have been added to the request body.

const provider = new GeoApiFrProvider({
searchUrl: 'https://api-adresse.data.gouv.fr/search',
reverseUrl: 'https://api-adresse.data.gouv.fr/reverse',
params: {
type: 'municipality', // limit search results to city
autocomplete: 1, // Use in autocomplete mode (search in prefix mode)
lat: 0, // Latitude in degree
lon: 0, // Longitude in degree
},
});