I have a JSON data with coordinates:
"geometry":{"type":"Point","coordinates":[95.9174,3.8394,59]},"id":"us10002b0v"
I am looking to extract each value in the coordinates
array that is comma separated. In PHP, I would use
extract(",",$geometry[coordinates]);
. Is there a way to achieve this in JavaScript?
The source JSON can be found here:
This snippet shows my current code:
google.maps.event.addDomListener(window, 'load', function() {
map = new google.maps.Map(document.getElementById('map-canvas'), {
center: { lat: 7.8, lng: 98.3},
zoom: 4,
styles: mapStyle
});
map.data.setStyle(styleFeature);
infowindow = new google.maps.InfoWindow({
content: '<div class = "corp" style="width: 260px; height: 200px">' + '</div>'
})
//InfoWindow
var infowindow = new google.maps.InfoWindow();
google.maps.event.addListener(map,'click',function() {
infowindow.close();
});
map.data.addListener('click', function(event) {
var place = event.feature.getProperty('place');
var mag = event.feature.getProperty('mag');
var depth = event.feature.getProperty('geometry');//I need the depth from this line which is arrayed
var link = event.feature.getProperty('url');
var jsonTime = event.feature.getProperty('time');
var humanTime = new Date('jsonTime');
infowindow.setContent('<div><h3>'+place+'</h3><p>Mag: '+mag+'<br />Depth '+depth+'<br />Time : '+humanTime+'<br /><a href="'+link+'" target="_blank">More</a></p></div>');
infowindow.setPosition(event.feature.getGeometry().get());
infowindow.setOptions({pixelOffset: new google.maps.Size(0,-30)});
infowindow.open(map);
});