Legacy Google Provider
WARNING: This provider is unsafe to use and should be considered DEPRECATED.
It is strongly suggested to use the new Google Provider. If you're currently migrating from a previous version
and you still wish to use this provider you should pull in the LegacyGoogleProvider
class
and rename your references accordingly.
note: Google services require an API key. Obtain here. For more options and configurations, see the Google Maps developer docs.
import { LegacyGoogleProvider } from 'leaflet-geosearch';const provider = new LegacyGoogleProvider({params: {key: '__YOUR_GOOGLE_KEY__',},});// add to leafletimport { GeoSearchControl } from 'leaflet-geosearch';map.addControl(new GeoSearchControl({provider,style: 'bar',}),);
Optional parameters
Google supports a number of optional parameters. As Google 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 LegacyGoogleProvider({params: {key: '__YOUR_GOOGLE_KEY__',language: 'nl', // render results in Dutchregion: 'nl', // prioritize matches within The Netherlands},});