json - 从经纬度坐标获取街景全景 ID

标签 json google-maps google-maps-api-3

我正在尝试从经纬度坐标获取街景全景 ID,我发现此查询将返回一个包含全景图的 JSON 文件(例如 JMUfE4l0ucICvD4_BaIGsw )。

https://cbks0.google.com/cbk?cb_client=apiv3&authuser=0&hl=en&output=polygon&it=1%3A1&rank=closest&ll=30.2983995,35.1334873&radius=50

只需将坐标替换为您喜欢的任何内容。

但这是我的问题:我怎样才能让它适用于像以色列小道这样的越野?当我输入这条越野小径的任何坐标时,它总是返回一个空的 JSON 文件。 (例如,我知道 30.7451333,34.8850511 是全景图,但它不会返回全景图。)我做错了什么?谢谢。

最佳答案

您用于获取全景 ID 的 URL 是未记录的功能。 Google map 的服务条款禁止通过此类 URL 访问服务。
查看服务条款的第 10.1 (a) 段。

No access to APIs or Content except through the Service. You will not access the Maps API(s) or the Content except through the Service. For example, you must not access map tiles or imagery through interfaces or channels (including undocumented Google interfaces) other than the Maps API(s).



https://developers.google.com/maps/terms#10-license-restrictions

您应该使用 Street View Image Metadata 的 API在你的情况下。

例如要获取 30.7451333,34.8850511 的全景 ID,您可以执行以下查询
https://maps.googleapis.com/maps/api/streetview/metadata?location=30.7451333%2C34.8850511&key=API_KEY
此请求返回以下响应
{
    "copyright":"© 2017 Google",
    "date":"2015-05",
    "location":{
        "lat":30.74513326023706,
        "lng":34.88505109084099
    },
    "pano_id":"Ig2uuF7itfCs8ksgjlJaTQ",
    "status":"OK"
 }

现在您有了全景 ID Ig2uuF7itfCs8ksgjlJaTQ。让它与街景 API 一起使用:

<img src="https://maps.googleapis.com/maps/api/streetview?pano=Ig2uuF7itfCs8ksgjlJaTQ&size=600x400" title="" />


希望能帮助到你!

关于json - 从经纬度坐标获取街景全景 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42019281/

相关文章:

php - 从 mysql 中检索数据并从 php 中输出 json

php自定义错误处理程序如何在生产中打印错误?

java - 如何计算 map 跨度/缩放以在视口(viewport)中包含一组 GeoPoints?

java - Android Studio 谷歌地图自定义 map ,只想显示自定义 map 但使用谷歌地图功能

google-maps - Google Maps API - 仅显示交通层?

google-maps - 从 geoJSON 获取 map 视口(viewport)中存在的要素

google-maps-api-3 - 如何正确使用 Google Maps API?

json - Swift Codable 解码更改 JSON 并忽略某些字段

json - 将 JSON 文件拆分为单独的文件

google-maps-api-3 - 以一种颜色获取 Google Map MarkerClusterer Plus 图标