With the attached patch,
the Geocoder module may provide the following API Url endpoints (with Json output), to be consumed for performing direct Geocode and Reverse Geocode operations respectively, allowing also easy and custom implementation of Geocode Autocomplete inputs to third party (dependent) modules.

Geocode

This endpoint allows to process a Geocode operation (get Geo Coordinates from Addresses) on the basis of an input Address, the operational Geocoders and an (optional) output Format (Dumper).

Path: '/geocoder/api/geocode'
Method: GET
Access Permission: 'access geocoder api endpoints'
Successful Response Body Format: json

Reverse Geocode

This endpoint allows to process a Reverse Geocode operation (get an Address from Geo Coordinates) on the basis of an input string of atitude and Longitude coordinates, the operational Geocoders and an (optional) output Format (Dumper).

Path: '/geocoder/api/reverse_geocode'
Method: GET
Access Permission: 'access geocoder api endpoints'
Successful Response Body Format: json

NOTE:

The patch updates/integrates the Readme.md file with API Endpoints use parameters details.

Comments

itamair created an issue. See original summary.

itamair’s picture

Priority: Normal » Major
Status: Active » Needs review
StatusFileSize
new11.71 KB
itamair’s picture

Issue summary: View changes
itamair’s picture

StatusFileSize
new11.82 KB

Switched too "geocoder" parameter name (singular) ...

itamair’s picture

StatusFileSize
new14.26 KB

added 'formatted_address' and 'geometry' properties to standard "array" geocoder outputs format, to harmonize to the googlemaps geocoder output.

  • itamair committed 0b31508 on 8.x-3.x
    Issue #3077010 by itamair: Geocoder API Url endpoints for performing...
itamair’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

1i1c’s picture

I recently installed Geocoder and think this will be a great feature. However, I cannot get the endpoint work with Google Maps

My assumption is that you can put the following site.com/geocoder/api/geocode?address=Address then the module will return JSON data from Google services. However, there is no response at all from the endpoint.

Please let me know if any further configurations are required

Thanks,

itamair’s picture

@Ingo ... from what you describe it looks you are not complying (and not reading) the Readme.md documentation on the Geocoding API End Point:
https://git.drupalcode.org/project/geocoder/-/blob/8.x-3.x/README.md#geo...

Besides the "address" parameter also the "geocoder" is a required one ...

Also your Drupal Logs should give you evidence of the thrown exception.