smeijer / leaflet-geosearch

A geocoding/address-lookup library supporting various api providers.
https://smeijer.github.io/leaflet-geosearch/
MIT License
1.03k stars 273 forks source link

How to get postal code back from search results? #232

Closed tbaustin closed 4 years ago

tbaustin commented 4 years ago

I'm not seeing a postal code/zip code coming back from the search results?

smeijer commented 4 years ago

That depends on the provider that you're using. For openstreetmap, you might want to include the addressdetails in your response.

Basically, you need to check the additional parameters that your provider supports (in the docs of that provider), and than pass that option to the constructor.

https://smeijer.github.io/leaflet-geosearch/providers/openstreetmap#optional-parameters

const provider = new OpenStreetMapProvider({
  params: {
    'accept-language': 'nl', // render results in Dutch
    countrycodes: 'nl', // limit search results to the Netherlands
    addressdetails: 1, // include additional address detail parts
  },
});

(closing because it's a question and not an issue. Please feel free to keep the discussion going if things aren't clear).