如何查看街景服务是否在位置上可用 [英] How to check is streetview is available on location

查看:115
本文介绍了如何查看街景服务是否在位置上可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google Maps Android SDK,并试图确定街景全景是否在特定位置.

I'm using the the Google Maps Android SDK and I'm trying to find out if a StreetView panorama is available is a certain location.

描述此功能:如果用户单击地图标记,并且该位置具有全景,则显示全景图,否则只需将地图缩放到标记位置)

To describe the feature: "If a user click on a map marker and a the location has a panorama then show the panoram, otherwise just zoom the map to the marker location)

如果该位置没有全景,则我不希望创建SupportStreetViewPanoramaFragment. 即使我创建了它,我认为唯一可行的方法是调用setOnStreetViewPanoramaChangeListener,然后调用setPosition并在侦听器上检查全景ID. 出于某种原因,没有打电话给听众,但我仍未尝试修复它,因为反正感觉太麻烦了.

I'd rather not create a SupportStreetViewPanoramaFragment if the location doesn't have a panorama. Even if I create it I think the only possible way would be to call setOnStreetViewPanoramaChangeListener and then call setPosition and check the panorama id on the listener... For some reason the listener wasn't called but I didn't try to fix it yet because its feels too cumbersome anyway.

这里有任何优雅的解决方案吗?

Any elegant solution here ?

我也希望(坚持)避免通过此链接调用JavaScript API v3: https://developers.google.com/maps/documentation/javascript/reference#StreetViewService

I also hope (insist) to avoid calling JavaScript API v3 following this link: https://developers.google.com/maps/documentation/javascript/reference#StreetViewService

var latLng = new google.maps.LatLng(lat, lon);
        streetViewService.getPanoramaByLocation(latLng, STREETVIEW_MAX_DISTANCE, function (streetViewPanoramaData, status) {
            if (status === google.maps.StreetViewStatus.OK) {
                //ok
            } else {
                //no ok
            }
        });

推荐答案

您可以使用街景视图元数据.如果它返回标记位置的pano_id,则说明效果不错.使用它需要一个API密钥,但不使用任何积分. 另一方面,当Google今年早些时候更改其云定价时,StreetView全景图的使用成本变得非常昂贵.因此,除非您肯定要使用它,否则不要实例化它.

You can use street view metadata. If it returns a pano_id for your marker's location you should be good. Using it needs an API key but it uses no credits. StreetView panorama, on the other hand, got super expensive to use when Google changed their cloud pricing earlier this year. So don't even instantiate one unless you are definitely going to use it.

https://developers.google.com/maps/documentation/streetview/metadata

这篇关于如何查看街景服务是否在位置上可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆