@Override public void onIndoorBuildingFocused() { IndoorBuilding building = mMap.getFocusedBuilding(); if (building != null && mMosconeBuilding == null && mMap.getProjection().getVisibleRegion().latLngBounds.contains(MOSCONE)) { // Store the first active building. This will always be Moscone mMosconeBuilding = building; } if (!mAtMoscone && building != null && building.equals(mMosconeBuilding)) { // Map is focused on Moscone Center mAtMoscone = true; onFocusMoscone(); } else if (mAtMoscone && mMosconeBuilding != null && !mMosconeBuilding.equals(building)) { // Map is no longer focused on Moscone Center mAtMoscone = false; onDefocusMoscone(); } onIndoorLevelActivated(building); }
public static JSONObject convertIndoorBuildingToJson(IndoorBuilding indoorBuilding) { if (indoorBuilding == null) { return null; } JSONObject result = new JSONObject(); try { JSONArray levels = new JSONArray(); for(IndoorLevel level : indoorBuilding.getLevels()){ JSONObject levelInfo = new JSONObject(); levelInfo.put("name",level.getName()); // TODO Auto-generated catch block levelInfo.put("shortName",level.getShortName()); levels.put(levelInfo); } result.put("activeLevelIndex",indoorBuilding.getActiveLevelIndex()); result.put("defaultLevelIndex",indoorBuilding.getDefaultLevelIndex()); result.put("levels",levels); result.put("underground",indoorBuilding.isUnderground()); } catch (JSONException e) { e.printStackTrace(); return null; } return result; }
@Override public void onIndoorBuildingFocused() { IndoorBuilding building = mMap.getFocusedBuilding(); if (building != null && mMosconeBuilding == null && mMap.getProjection().getVisibleRegion().latLngBounds.contains(MOSCONE)) { // Store the first active building. This will always be Moscone mMosconeBuilding = building; enableMapElements(); } if (building != null && mMosconeBuilding.equals(building)) { // Map is focused on Moscone Center mAtMoscone = true; onFocusMoscone(); } else if(mAtMoscone){ // Map is no longer focused on Moscone Center mAtMoscone = false; onDefocusMoscone(); } }
/** * Called when the focused building info is clicked. */ public void onFocusedBuildingInfo(View view) { IndoorBuilding building = mMap.getFocusedBuilding(); if (building != null) { String s = ""; for (IndoorLevel level : (List<IndoorLevel>) building.getLevels()) { s = s + level.getName() + " "; } if (building.isUnderground()) { s += "is underground"; } setText(s); } else { setText("No visible building"); } }
/** * Called when the activate higher level is clicked. */ public void onHigherLevel(View view) { IndoorBuilding building = mMap.getFocusedBuilding(); if (building != null) { List<IndoorLevel> levels = building.getLevels(); if (!levels.isEmpty()) { int currentLevel = building.getActiveLevelIndex(); // The levels are in 'display order' from top to bottom, // i.e. higher levels in the building are lower numbered in the array. int newLevel = currentLevel - 1; if (newLevel == -1) { newLevel = levels.size() - 1; } IndoorLevel level = levels.get(newLevel); setText("Activiating level " + level.getName()); level.activate(); } else { setText("No levels in building"); } } else { setText("No visible building"); } }
@SuppressWarnings("unused") private void getFocusedBuilding(final JSONArray args, final CallbackContext callbackContext) throws JSONException { IndoorBuilding focusedBuilding = map.getFocusedBuilding(); if (focusedBuilding != null) { JSONObject result = PluginUtil.convertIndoorBuildingToJson(focusedBuilding); callbackContext.success(result); } else { callbackContext.success(-1); } }
@Override public void onIndoorLevelActivated(IndoorBuilding building) { String jsonStr = "null"; JSONObject result = PluginUtil.convertIndoorBuildingToJson(building); if (result != null) { jsonStr = result.toString(); } webView.loadUrl("javascript:plugin.google.maps.Map._onMapEvent('indoor_level_activated', " + jsonStr + ")"); }
@Override public void onIndoorLevelActivated(IndoorBuilding indoorBuilding) { if (indoorBuilding.equals(mMosconeBuilding)) { // Show map elements for this floor if at Moscone showFloorElementsIndex(indoorBuilding.getActiveLevelIndex()); } }
/** * Called when the focused level info is clicked. */ public void onVisibleLevelInfo(View view) { IndoorBuilding building = mMap.getFocusedBuilding(); if (building != null) { IndoorLevel level = (IndoorLevel) building.getLevels().get(building.getActiveLevelIndex()); if (level != null) { setText(level.getName()); } else { setText("No visible level"); } } else { setText("No visible building"); } }
@Override public void onIndoorLevelActivated(IndoorBuilding indoorBuilding) { if (indoorBuilding != null && indoorBuilding.equals(mMosconeBuilding)) { onMosconeFloorActivated(indoorBuilding.getActiveLevelIndex()); } }