node-geocoder icon indicating copy to clipboard operation
node-geocoder copied to clipboard

How to set limit of results in openstreetmap

Open flamurbeqiri1 opened this issue 3 years ago • 4 comments

I use the provider openstreetmap and according to documentation it says we can use the nominatim properties. How can we e.x use the limit for geocode.

Currently I have: let results: any = await geocoder.geocode(query);

The initialiser requires only the query string :/

flamurbeqiri1 avatar Nov 18 '22 20:11 flamurbeqiri1

Hi I just added an example test on how you can use openstreetmap with custom props https://github.com/nchaulet/node-geocoder/blob/master/integration_test/geocoder/openstreetmapgeocoder.test.js#L30

nchaulet avatar Nov 20 '22 21:11 nchaulet

How does it work on your case when i get: Argument of type '{ q: string; limit: number; }' is not assignable to parameter of type 'string | Query'. Object literal may only specify known properties, and 'q' does not exist in type 'Query'.ts(2345) And i see there is no "q" in the Query Interface!

flamurbeqiri1 avatar Nov 20 '22 22:11 flamurbeqiri1

Oh I guess the types probably need to be updated, the node-geocoder module is not written in typescript and types are coming from DefinitelyTyped/DefinitelyTyped. You can probably temporarly fix this in your code with a ts-expect-error or ts-ignore comment

nchaulet avatar Nov 20 '22 23:11 nchaulet

Ok, thnx

flamurbeqiri1 avatar Nov 21 '22 16:11 flamurbeqiri1