我正在构建一个 Instagram 地图应用程序,并尝试使用 $.each 遍历返回的 JSON。我目前正在通过将图片的坐标返回到<div>
. 它工作得很好,除了相同的数据出现两次。这是声明(注释掉的代码用于将其放在地图上):
$.each(photos.data, function (index, photo) {
if (photo.location) {
/* var photocoords = google.maps.LatLng(photo.location.latitude,location.longitude);
var marker = new google.maps.Marker({
position: photocoords,
map: map,
title: 'Test'
});//end new marker
*/
photo = photo.location.latitude + ' , ' + photo.location.longitude + '<br>';
$('#photos-wrap').append(photo);
} //end if
else {
return true
}
});
它返回的数据:
38.9232268 , -77.0464289
35.046506242 , -90.025382579
35.189142533 , -101.987259233
38.9232268 , -77.0464289
35.046506242 , -90.025382579
35.189142533 , -101.987259233
感谢您的任何帮助,您可以提供。