Skip to content

limit results geocoder #1224

Open
Open
@passasooz

Description

@passasooz

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?

Activity

jbelien

jbelien commented on May 25, 2024

@jbelien
Member

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      limit results geocoder · Issue #1224 · geocoder-php/Geocoder