本文介绍了StreetViewService getPanorama方法报告LatLng巴黎的错误状态代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

突然之间,我似乎从Google Maps JavaScript API获取了不准确的状态代码。例如,使用以下代码:

  sv.getPanorama({
location:{lat:35.685,lng:139.7514 },
radius:350
},function(data,status){
console.log(getPano()location =+ data.location.latLng);
console .log(getPano()panoID =+ data.location.pano);
console.log(getPano()status =+ status);
});

借此,我得到以下输出:

  new getPano()location =(35.685175,139.75279950000004)
getPano()panoID = F:-2eRkGOODHZg / VtKZ7EGeepI / AAAAAAAADLY / Fvhw3HeTfXcAVq0wuHxq22LnoTtpeUx2A
getPano = OK

当我尝试根据此数据构建请求URL时,例如:

  https://maps.googleapis.com/maps/api/streetview?size=640x540&location=35.685175,139.75279950000004 

或随pano ID:

  https://maps.googleapis.com/maps/api/streetview?size=640x540&pano=F:-2eRkGOODHZg/VtKZ7EGeepI/AAAAAAAADLY/Fvhw3HeTfXcAVq0wuHxq22LnoTtpeUx2A 

我收到对不起,我们这里没有图像。图片。换句话说,即使状态回到 OK ,这个位置没有可用的pano。手动访问Google地图的这个 latLng 会证明这一点。谷歌确实有该地点的卫星图像,但不是街景视图。



这段代码曾经工作过,所以我对发生的事情感到困惑。为什么当panoID和latLng指向没有图像时,API为这个位置返回OK pano状态?



更新:
我将不胜感激任何确认对其他人的调查结果是一样的(例如,这不是我做错的事),以及任何变通办法的想法。我的应用程序是为街道位置提供静态街景图像的应用程序,但如果没有可用的街景图像,我会转移到卫星。我使用getPanorama()状态来确定要采用哪个方向。 解决方案

API可以让您查询在给定位置是否有街景视图全景图,并且只会返回在街景图片API中实际可用的全景图。这会让您摆脱 。



地点可以通过地址或latlng指定。如果找到全景图,则响应将包含要在Street View Image API请求中使用的全景图ID。这些元数据查询是免费的。


All of the sudden I appear to be getting inaccurate status codes from the Google Maps Javascript API. For example, with this code:

sv.getPanorama({
    location: {lat: 35.685, lng: 139.7514}, 
    radius: 350
  }, function(data, status) {
    console.log("getPano() location = "+data.location.latLng);
    console.log("getPano() panoID = "+data.location.pano);
    console.log("getPano() status = "+status);
});

With this, I get the following output:

new getPano() location = (35.685175, 139.75279950000004)
getPano() panoID = F:-2eRkGOODHZg/VtKZ7EGeepI/AAAAAAAADLY/Fvhw3HeTfXcAVq0wuHxq22LnoTtpeUx2A
getPano() status = OK

When I try to build a request URL based on this data, such as:

https://maps.googleapis.com/maps/api/streetview?size=640x540&location=35.685175,139.75279950000004

or with the pano ID:

https://maps.googleapis.com/maps/api/streetview?size=640x540&pano=F:-2eRkGOODHZg/VtKZ7EGeepI/AAAAAAAADLY/Fvhw3HeTfXcAVq0wuHxq22LnoTtpeUx2A

I get the "Sorry, we have no imagery here." image. In other words, even though the status came back as OK, there is no pano available at this location. Visiting Google Maps manually for this latLng bears this out. Google does have satellite imagery for that location, but not a Street View pano.

This code used to work, so I'm confused as to what is going on. Why is the API returning an OK pano status for this location when the panoID and latLng point to no image?

UPDATE:I would appreciate any confirmations that my findings are the same for others (e.g. that it's not something I'm doing wrong), and, any ideas for workarounds. My app is one that pulls up static street view images for latLng locations, but if there isn't a street view image available I shift to satellite. I use the getPanorama() status to determine which direction to take.

解决方案

The new Street View Image Metadata API will let you query for the availability of Street View panoramas at given locations, and it will only return panoramas that are actually available in the Street View Image API. This will get you rid of Issue 10335.

Locations may be specified by address or latlng. If a panorama is found, the response will include the pano ID, to use in the Street View Image API request. These metadata queries are free of charge.

这篇关于StreetViewService getPanorama方法报告LatLng巴黎的错误状态代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 13:37