【发布时间】:2014-03-17 19:56:58
【问题描述】:
我正在使用 Instagram API,我正在尝试通过将 Instagram 图片中的经度和纬度存储在 JSON 文件中来在 Google 地图上创建标记。
这是我来自 Instagram API 并创建 JSON 文件的代码
<?php
$lat = 51.917367;
$lon = 4.462299;
$client_id = "my-client-id";
$link = 'https://api.instagram.com/v1/media/search?lat=' . $lat . '&lng=' . $lon . '&client_id=' . $client_id . '&distance=200';
$data = file_get_contents($link);
$result = json_decode($data);
$locations = [];
foreach ($result->data as $post):{
$images = $post->images->thumbnail->url;
$latitude = $post->location->latitude;
$longitude = $post->location->longitude;
$locations [] = ["longitudes"=>$longitude, "latitudes"=>$latitude, "images"=>$images];
} endforeach;
header("Content-Type: application/json");
echo json_encode($locations);
exit;
我的问题是如何使用 AJAX 从 JSON 文件中获取经度和纬度,然后在谷歌地图上的这个位置创建一个标记(使用图像)。
【问题讨论】:
标签: ajax json api google-maps instagram