谷歌地图获取当前楼层 [英] Google map get current floor

查看:33
本文介绍了谷歌地图获取当前楼层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android应用程序中使用了新的Google地图.我的大楼有不同的楼层.我需要取得当前发言权.

I'm using new Google map in my android application. I have different floors in my building. I need to get current floor.

推荐答案

前一段时间,您问...今天,我找到了一个解决方案.首先,您需要最新的google-play-services_lib(v4.4).在Eclipse中,通过SDK Manager更新Play服务,然后按照设置进行操作.然后,您需要实现 OnIndoorStateChangeListener 在你的活动中.不要忘记将您的活动设置为GoogleMap的侦听器.例如:

A while ago you asked... today I found a solution. First of all, you need the latest google-play-services_lib (v4.4). In Eclipse, update Play Services via the SDK Manager and follow the Setup. Then you need to implement the OnIndoorStateChangeListener in your activity. Don't forget to to set your activity as listener to your GoogleMap. E.g:

public class YourActivity implements OnIndoorStateChangeListener {

   @Override
   protected void onCreate(Bundle savedInstanceState) {
      ...
      yourGoogleMap.setOnIndoorStateChangeListener(this);
   }

   @Override
   public void onIndoorLevelActivated(IndoorBuilding indoorBuilding) {
      List<IndoorLevel> levels = indoorBuilding.getLevels();
      for (IndoorLevel indoorLevel : levels) {
         indoorLevel.get...
      }
   }

当您的建筑物上的地图上有室内信息时,您会通过回调收到一个 IndoorBuilding 对象.从此 IndoorBuilding 中,您可以获取 IndoorLevels 的列表,并在 IndoorLevel 中找到一些吸气剂.

When you have a building with indoor information on your map you receive a IndoorBuilding object via callback. From this IndoorBuilding you can get a list of IndoorLevels and inside the IndoorLevel you find a few getters.

调用 indoorBuilding.getActiveLevelIndex()时,GoogleMaps从屋顶到地下室进行计数-与在 IndoorLevel 列表上进行迭代的方向相同.这意味着,您可以在6英尺以下找到最大的高度索引.

When you call indoorBuilding.getActiveLevelIndex(), GoogleMaps counts from the roof to the basement - the same direction you iterate over the IndoorLevel list. This means, that you could find the maximum level index six feet under.

希望,这会有所帮助!

更新:我找到了一个更好的解决方案...

UPDATE: I found a better solution...

IndoorBuilding yourBuilding = yourGoogleMap.getFocusedBuilding();
List<IndoorLevel> levels = yourBuilding.getLevels();
String name = levels.get(yourBuilding.getActiveLevelIndex()).getName();
String shortName = levels.get(yourBuilding.getActiveLevelIndex()).getShortName();

这篇关于谷歌地图获取当前楼层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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