Closed mvaneijgen closed 5 years ago
For now I've loaded my external .json
file from there created a new json
object with the correct key
/value
pair and fed that to the dataRaw
object. This is what it looks like
<?php
$base = 'URL-TO-MY-API.com;
$posttype = "school";
$queries = "?orderby=date&order=desc&per_page=100&_embed";
$dataURL = $base . $posttype . $queries; // path to your JSON file
$JSON = file_get_contents($dataURL);
$JSONraw = json_decode($JSON, true);
$JSONclean = array();
?>
<?php foreach ($JSONraw as $item): ?>
<?php
$pushItem = array(
'id' => $item['id'],
'title' => $item['title']['rendered'],
'lat' => $item['acf']['contact_locations'][0]['latitude'],
'lng' => $item['acf']['contact_locations'][0]['longitude'],
);
array_push($JSONclean, $pushItem);
?>
<?php endforeach; ?>
than within the .storeLocator()
options I load
$("#bh-sl-map-container").storeLocator({
...
dataRaw:<?php echo json_encode($JSONclean) ?>,
dataType: "json",
...
});
I have data coming from an external API (JSON) where the data is formatted in a different way than the example. My longitude and latitude are note formatted like this
But look like this
So I would figure I need to access them in the like
contact_locations.latitude
, but I have no idea where to set them... Is there a tutorial how to work with this plugin?