【问题标题】:StreetViewPanorama.getLocation always return null.StreetViewPanorama.getLocation 始终返回 null。
【发布时间】:2016-05-31 16:52:00
【问题描述】:

我在我的 Activity 中使用 StreetViewPanorama View。

最初我使用 StreetViewPanorama 设置位置。

streetViewPanorama.setPosition(new LatLng(25.1305784, 55.1170592));

但是在我尝试获取该位置的 Nearer PanoIds 之后,它总是返回 null 值以下是我编写的代码:

StreetViewPanoramaLocation location = streetViewPanorama.getLocation();

Log.d("test","LocaTion:"+location);
if (location != null && location.links != null) {

       Log.d("test","size:"+location.links.length);

            streetViewPanorama.setPosition(location.links[0].panoId);
 }  

请帮助我,在此先感谢。

【问题讨论】:

    标签: android android-maps-v2 android-location


    【解决方案1】:

    该位置有时会返回空值,因为它可能尚未加载。只需检查它是否存在。来自another post

     @Override
     public void onStreetViewPanoramaReady(StreetViewPanorama streetViewPanorama) {
     mPanorama.setOnStreetViewPanoramaChangeListener(new StreetViewPanorama.OnStreetViewPanoramaChangeListener() {
          @Override
          public void onStreetViewPanoramaChange(StreetViewPanoramaLocation   streetViewPanoramaLocation) {
            if (streetViewPanoramaLocation != null && streetViewPanoramaLocation.links != null) {
                // location is present
            } else {
                // location not available
            }
        }
      });
    

    【讨论】:

      猜你喜欢
      • 2015-08-15
      • 2012-03-18
      • 2016-11-04
      • 2016-07-28
      • 2010-11-08
      • 2017-11-26
      • 2015-02-23
      • 2017-11-16
      • 1970-01-01
      相关资源
      最近更新 更多