Google Map Get Current Floor
Solution 1:
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:
publicclassYourActivityimplementsOnIndoorStateChangeListener {
@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
...
yourGoogleMap.setOnIndoorStateChangeListener(this);
}
@OverridepublicvoidonIndoorLevelActivated(IndoorBuilding indoorBuilding) {
List<IndoorLevel> levels = indoorBuilding.getLevels();
for (IndoorLevel indoorLevel : levels) {
indoorLevel.get...
}
}
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.
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.
Hope, this helps!
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();
Post a Comment for "Google Map Get Current Floor"