Here is the structure of my php file:
$lab = array(
"repartition" => array (
array(
"latLng" => array( xxx, xxx ),
"name" => "Paris",
"code" => "FR-75"
)
),
array (
"latLng" => array( xxx, xxx ),
"name" => "Grenoble",
"code" => "FR-38"
)
)
I just wondering if I can retrieve the LatLng array from an address public API.
https://api-adresse.data.gouv.fr/search/?q=paris&limit=1
In the vectorMap, I was able to retrieve the appropriate values as below, but it's on MarkerClick:
onMarkerClick: function(event, index) {
var city= data2[0].repartition[index].name;
//var latt = data2[0].repartition[index].latLng[0];
//var long = data2[0].repartition[index].latLng[1];
$.getJSON("https://api-adresse.data.gouv.fr/search/?q=" + city+ "&limit=1", function (dt){
var newlatt = dt.features[0].geometry.coordinates[1];
var newlong = dt.features[0].geometry.coordinates[0];
})
But I wasn't able to retrieve it on the markers value. Markers is coded like that:
markers: data2[0].repartition,
My best way then is to create a function in php, but I don't know how to create it and retrieve the values in "latLng" => array( xxx, xxx ).
Thanks in advance for your help.
The best way use restful api in php :