I have an array of markers for Google Maps that is structured like this:
markers: [{
position: {
lat: 37.0636782,
lng: -8.0288746
},
infoText: 'Marker 1'
}],
In addition, I have data retrieved from my CMS in the following format:
[{
"latitude": "37.0636782",
"longitude": "-8.0288746",
"info_snippet": "test123"
},
{
"latitude": "37.0636789",
"longitude": "-8.0288745",
"info_snippet": "test111"
}]
My goal is to transform the second array to match the structure of the first array. Is this achievable?
Below is the loop I've implemented for this task.
this.pins = response.data.acf.map_markers;
let self = this;
this.pins.forEach(function(item) {
self.markers.position.lat.push(item.latitude);
self.markers.position.lng.push(item.longitude);
self.markers.infoText.push(item.info_snippet);
})