Geocoding via AJAX
If your users need to perform an address lookup without loading a new page, you would of course use AJAX to handle that. The format of the results depends on which endpoint you are using.
# /all
Returns results
as an array of Address Models, or an empty array if nothing is found.
const endpoint = '/actions/google-maps/lookup/all';
# /one
Returns results
as a single Address Model, or null
if nothing is found.
const endpoint = '/actions/google-maps/lookup/one';
# /coords
Returns results
as a single set of coordinates, or null
if nothing is found.
const endpoint = '/actions/google-maps/lookup/coords';
# AJAX Response
The response of each AJAX call will come in the following format:
{
success: bool,
error: string|null,
results: mixed // depends on which endpoint
}
Formatting Results
The results
value will be formatted according to which endpoint you are pinging.
The Google Maps plugin is not opinionated, how you perform the AJAX call is entirely up to you. You can get an idea of how the endpoints work by studying the AJAX geocoding example...