S
S
semki0962019-09-01 16:00:39
Drupal
semki096, 2019-09-01 16:00:39

How to get geodata on Drupal 8 using mapbox api as an example?

Let's say I need to get the address by coordinates or vice versa. Mapbox api gives this possibility, sample request

$ curl "https://api.mapbox.com/geocoding/v5/mapbox.places/starbucks.json?bbox=-77.083056,38.908611,-76.997778,38.959167&access_token=pk.eyJ1Ijoic2Vta2kwOTYiLCJhIjoiY2swMHhlNXNrMDg4eTNpbGN6MmFxaDZsaiJ9.rSaH9H66GaW5QEd_mqPzHQ"

I do not want to use ready-made modules for a simple task, especially since I did not find them. The task is to convert the address into coordinates and write them in a hidden field (I think so, maybe wrong). How to do it? Maybe there really are some ready-made solutions? This is Drupal 8.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
andead, 2019-09-01
@semki096

$response = file_get_contents('https://api.mapbox.com/geocoding/v5/mapbox.places/starbucks.json?bbox=-77.083056,38.908611,-76.997778,38.959167&access_token=pk.eyJ1Ijoic2Vta2kwOTYiLCJhIjoiY2swMHhlNXNrMDg4eTNpbGN6MmFxaDZsaiJ9.rSaH9H66GaW5QEd_mqPzHQ');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question