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

add query restriction option to open street map provider #183

Closed ahmdsamir91 closed 4 years ago

smeijer commented 5 years ago

Are the already supported (and native Nominatim) parameters insufficient?

https://wiki.openstreetmap.org/wiki/Nominatim#Parameters

countrycodes=[,][,]...

Limit search results to a specific country (or a list of countries).

should be the ISO 3166-1alpha2 code, e.g. gb for the United Kingdom, de for Germany, etc. **viewbox**=,,, The preferred area to find search results. Any two corner points of the box are accepted in any order as long as they span a real box.
// import
import { OpenStreetMapProvider } from 'leaflet-geosearch';

// setup
const provider = new OpenStreetMapProvider({
  params: {  
    viewbox: '...',
    countrycode: 'nl',
  }
});

// search
const results = await provider.search({ query: input.value });
smeijer commented 5 years ago

Even if that would be insufficient, wouldn't it be enough to wrap the search command?

// search
const results = await provider.search({ query: input.value + ' your modifier' });
ahmdsamir91 commented 5 years ago

Are the already supported (and native Nominatim) parameters insufficient?

https://wiki.openstreetmap.org/wiki/Nominatim#Parameters

countrycodes=[,][,]... Limit search results to a specific country (or a list of countries). should be the ISO 3166-1alpha2 code, e.g. gb for the United Kingdom, de for Germany, etc. viewbox=,,, The preferred area to find search results. Any two corner points of the box are accepted in any order as long as they span a real box.

// import
import { OpenStreetMapProvider } from 'leaflet-geosearch';

// setup
const provider = new OpenStreetMapProvider({
  params: {  
    viewbox: '...',
    countrycode: 'nl',
  }
});

// search
const results = await provider.search({ query: input.value });

i tried to add use the parameter but it didn't restrict the user query. after search i found out that parameter and query doesn't work together you can only use one of them.

Even if that would be insufficient, wouldn't it be enough to wrap the search command?

// search
const results = await provider.search({ query: input.value + ' your modifier' });

this will do it but i have to re redo all the customization you did the search-box.

i think it will a good feature to add restriction on the user query with out having to re-do the customization.

smeijer commented 4 years ago

My apologies for the long wait. I'm going to close this one, and will think of a solution on the higher level so that all providers can use some query manipulation before the request is being send. That solution will be tracked in #215.

At the same time, I've updated the docs to provide more information about how to limit results by using the providers' optional parameters.

Again, thanks for taking the trouble of opening a PR, and my apologies for the long wait.