Skip to content

GoogleMapsProvider uses invalid url for reverse lookup #550

@arubacao

Description

@arubacao

The Google Maps Provider uses the same endpoint for geocode and reverse lookup.
https://github.com/geocoder-php/Geocoder/blob/master/src/Geocoder/Provider/GoogleMaps.php#L33

'https://maps.googleapis.com/maps/api/geocode/json?address=%s';

Unfortunately, this is the wrong endpoint (or rather param) for reverse lookup. Prove:

Reverse: https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&key=YOUR_API_KEY

Geocode: https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=YOUR_API_KEY

Although it's currently not the correct endpoint, it somehow works since google is smart enough to figure that out.
However, if you want to use result_type or location_type as request parameters they will just be ignored. (Reference to #546)

I'm able to send a PR to fix this.

My approach:

  1. Get inspired by how the other providers (e.g. BingMaps )handle different endpoints

  2. Implement it for the GoogleMapsProvider

Please add your thoughts and comments & tell me if you approve this approach.
I'd appreciate a quick answer, so I can get started fast.

Cheers,
Chris

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions