Upgrading from 2.x to 3.0
3.0 is a rewrite in TypeScript with a new build. The control and the built-in providers are used the same way: new GeoSearchControl({ provider }), the same options and the same events. What changed are the file names in the package, custom providers, and a limit on the suggestions. If you go further to 5.x, read 3.x to 4.0 and 4.x to 5.0 next.
Dependencies and requirements
Updating the package
The imports stay the same:
Files in the package
If you import the stylesheet or load the browser build by path, change the path:
The browser build still puts everything on window.GeoSearch, and Leaflet has to be loaded before it. 3.x has no dist/bundle.min.js. 5.x has it again, as a copy of the browser build.
Suggestions are limited to 5
3.0 shows at most 5 suggestions, 2.x showed every result of the provider. maxSuggestions sets the number:
Requests use https
2.x used the protocol of the page for provider requests, so a page on http: asked the provider over http:. 3.0 always uses https:. Nothing to do, unless you run a provider of your own that only answers over http:.
Custom providers
The base class of the providers is exported as JsonProvider, Provider is gone. endpoint gets { query, type } instead of { query, protocol }, and returns the full https: url:
parse({ data }) and the shape of a result (x, y, label, bounds, raw) are the same. See Custom providers for the current version.
The OpenStreetMap provider of 2.x looked up a picked suggestion again with endpointReverse. That method is gone in 3.0. Since 5.0, provider.reverse() does reverse geocoding: Reverse geocoding.
New in 3.0
- the HERE, OpenCage and Algolia providers (Algolia was removed again in 4.0), and
LocationIQProviderin the main export (2.x had the file, but didn't export it) maxSuggestions- TypeScript types