I'm using the drupal/Geolocation module to assign a location field to a specific content-type.
I have created a View (REST Export display) to return all the content-type entries with all the fields and it's working fine.
I'd like to calculate the distance between a sent lat/lng point and the location of each entry and sort them by distance (and also include it in the resulting JSON).
I'm already applying some changes to the JSON output using the
views_post_render hook (and changing the
$output variable), but I don't think in that hook I can access a query string (sent via Ajax request).
What would be the best way to pass the user's location from the website frontend to the view? Right now my bet would be sending the query parameter via an Ajax request, adding something like
?location=-17.000,19.000 to the URL.
And where could I access that data (the user's lat/lng location) and calculate the distance to pass it again to the frontend?