下面是我的 JSON 格式。
{
"Data": {
"-template": "Parallax",
"Explore": {
"IslandLife": {
"TourismLocation": [
{
"Title": "Langkawi",
"Latitude": "6.350000",
"Longitude": "99.800000",
"YouTubePlaylistID": "UUnTJRksbHP4O8JSz00_XRQA",
"VideosList": {
"YouTubeVideoID": [
"7HlMpaSspNs",
"tzeRnbd77HU",
"VkIAbDIVJCA",
"ksJ6kwTe9wM"
]
}
},
{
"Title": "Rawa Island",
"Latitude": "2.520278",
"Longitude": "103.975833",
"YouTubePlaylistID": "UUnTJRksbHP4O8JSz00_XRQA",
"VideosList": { "YouTubeVideoID": "Kx0dUWaALKo" }
},
{
"Title": "Perhentian Island",
"Latitude": "5.903788",
"Longitude": "102.753737",
"YouTubePlaylistID": "UUnTJRksbHP4O8JSz00_XRQA",
"VideosList": {
"YouTubeVideoID": [
"ZpcdGk5Ee0w",
"TQTDOGpflZY"
]
}
},
{
"Title": "Sabah Marine Park",
"Latitude": "4.623326",
"Longitude": "118.719800",
"YouTubePlaylistID": "UUnTJRksbHP4O8JSz00_XRQA",
"VideosList": { "YouTubeVideoID": "VCDTEKOqpKg" }
}
]
}
}
}
}
并使用此函数下方,我正在从 Json 检索数据
$.getJSON('json/explore.json', function(data) {
$.each(data, function(key, val) {
for (var i = 0; i < val.Explore.IslandLife.TourismLocation.length; i++) {
console.log(val.Explore.IslandLife.TourismLocation[i].Title);
console.log(val.Explore.IslandLife.TourismLocation[i].Description);
console.log(val.Explore.IslandLife.TourismLocation[i].Latitude);
console.log(val.Explore.IslandLife.TourismLocation[i].Longitude);
console.log(val.Explore.IslandLife.TourismLocation[i].YouTubePlaylistID);
}
});
});
那么如何将“纬度”和“经度”绘制成双维数组?
我想要这样的数组对象??
var locations = [
['Langkawi', 6.350000, 99.800000, 4],
['Rawa Island', 2.520278, 103.975833, 3],
['Perhentian Island', 5.903788, 102.753737, 2],
['Sabah Marine Park', 4.623326, 118.719800, 1]
];
提前感谢:)