Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

limit results geocoder #1224

Open
passasooz opened this issue Apr 8, 2024 · 1 comment
Open

limit results geocoder #1224

passasooz opened this issue Apr 8, 2024 · 1 comment
Labels

Comments

@passasooz
Copy link

Hi, i've this code

$httpClient = new \GuzzleHttp\Client(); $provider = new \Geocoder\Provider\GoogleMaps\GoogleMaps($httpClient, null, env('GOOGLE_MAPS_API_KEY')); $geocoder = new \Geocoder\StatefulGeocoder($provider, 'it'); $result = $geocoder->reverseQuery(ReverseQuery::fromCoordinates($latitude, $longitude));

if I try to add ->limit(10) before ->reverseQuery it returns error "message": "Call to undefined method Geocoder\StatefulGeocoder::limit()",

i.e. $result = $geocoder->limit(10)->reverseQuery(ReverseQuery::fromCoordinates($latitude, $longitude)); returns this error, how can I fix it?

@jbelien
Copy link
Member

jbelien commented May 25, 2024

Hello @passasooz,

The limit() function exists on the GeocodeQuery and ReverseQuery classes, not the StatefulGeocoder class.

The correct call is:

$geocoder->reverseQuery(ReverseQuery::fromCoordinates($latitude, $longitude)->limit(10));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants