StreetViewService getPanorama method reporting Incorrect Status Codes for LatLng paris

半世苍凉 提交于 2019-12-11 05:55:42

问题


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.


回答1:


Since a few days ago, google.maps.StreetViewService.getPanorama() is indeed returning panos that cannot be displayed in the JavaScript API.

This is an issue in the API, please start it on the issue tracker to get updates:

Issue 10335: Bug: StreetViewService getPanorama() reporting incorrect status for many latLng pairs




回答2:


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.




回答3:


There is a separate feature request in the public issue tracker to enable access to panoramas with a pano ID like F:-2eRkGOODHZg/VtKZ7EGeepI/AAAAAAAADLY/Fvhw3HeTfXcAVq0wuHxq22LnoTtpeUx2A in the Street View Image API:

https://issuetracker.google.com/issues/35829459

If you are interested in this feature please star the feature request to add your vote.

UPDATE

The feature request that I mentioned before is now marked as Fixed.

Google implemented access to User Generated content via the Street View Image API. However, the pano ID format has been changed during this process.

For example, you mentioned the pano ID F:-2eRkGOODHZg/VtKZ7EGeepI/AAAAAAAADLY/Fvhw3HeTfXcAVq0wuHxq22LnoTtpeUx2A.

Now the new pano ID for this panorama is CAMSRi0yZVJrR09PREhaZy9WdEtaN0VHZWVwSS9BQUFBQUFBQURMWS9Gdmh3M0hlVGZYY0FWcTB3dUh4cTIyTG5vVHRwZVV4MkE.

You can easily convert previous pano IDs to the new ones using the Street View Image Metadata requests that are free of charge and don't consume your quota:

https://maps.googleapis.com/maps/api/streetview/metadata?pano=F%3A-2eRkGOODHZg%2FVtKZ7EGeepI%2FAAAAAAAADLY%2FFvhw3HeTfXcAVq0wuHxq22LnoTtpeUx2A&key=YOUR_API_KEY

{
    "copyright":"© Alberto Saito","date":"2016-02",
    "location":{
        "lat":35.685175,
        "lng":139.7527995
    },"pano_id":"CAMSRi0yZVJrR09PREhaZy9WdEtaN0VHZWVwSS9BQUFBQUFBQURMWS9Gdmh3M0hlVGZYY0FWcTB3dUh4cTIyTG5vVHRwZVV4MkE.",
    "status":"OK"
}

Now apply the new pano ID and enjoy:

https://maps.googleapis.com/maps/api/streetview?pano=CAMSRi0yZVJrR09PREhaZy9WdEtaN0VHZWVwSS9BQUFBQUFBQURMWS9Gdmh3M0hlVGZYY0FWcTB3dUh4cTIyTG5vVHRwZVV4MkE.&size=600x400&key=YOUR_API_KEY



来源:https://stackoverflow.com/questions/39033481/streetviewservice-getpanorama-method-reporting-incorrect-status-codes-for-latlng

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!