Skip to content

Commit

Permalink
Merge pull request DroidPlanner#258 from arthurbenemann/BugFix_issue256
Browse files Browse the repository at this point in the history
Quick bug fix for issue DroidPlanner#256
  • Loading branch information
arthurbenemann committed Aug 24, 2013
2 parents 861d1e9 + 279499a commit 7f5b45e
Showing 1 changed file with 19 additions and 19 deletions.
Expand Up @@ -23,6 +23,8 @@

public class OfflineMapFragment extends MapFragment {

private GoogleMap mMap;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup,
Bundle bundle) {
Expand All @@ -32,19 +34,21 @@ public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup,
}

private void setupMap() {
setupMapUI();
setupMapOverlay();
mMap = getMap();
if (isMapLayoutFinished()) { // TODO it should wait for the map layout
// before setting it up, instead of just
// skipping the setup
setupMapUI();
setupMapOverlay();
}
}

private void setupMapUI() {
GoogleMap mMap = getMap();
if (mMap != null) {
mMap.setMyLocationEnabled(true);
UiSettings mUiSettings = mMap.getUiSettings();
mUiSettings.setMyLocationButtonEnabled(true);
mUiSettings.setCompassEnabled(true);
mUiSettings.setTiltGesturesEnabled(false);
}
mMap.setMyLocationEnabled(true);
UiSettings mUiSettings = mMap.getUiSettings();
mUiSettings.setMyLocationButtonEnabled(true);
mUiSettings.setCompassEnabled(true);
mUiSettings.setTiltGesturesEnabled(false);
}

private void setupMapOverlay() {
Expand All @@ -63,7 +67,6 @@ private boolean isOfflineMapEnabled() {
}

private void setupOnlineMapOverlay() {
GoogleMap mMap = getMap();
mMap.setMapType(getMapType());
}

Expand All @@ -89,7 +92,6 @@ private int getMapType() {
}

private void setupOfflineMapOverlay() {
GoogleMap mMap = getMap();
mMap.setMapType(GoogleMap.MAP_TYPE_NONE);
TileOverlay tileOverlay = mMap.addTileOverlay(new TileOverlayOptions()
.tileProvider(new LocalMapTileProvider()));
Expand All @@ -110,10 +112,6 @@ public void zoomToExtents(List<LatLng> pointsList) {
}
}

private boolean isMapLayoutFinished() {
return getMap() != null;
}

protected void clearMap() {
GoogleMap mMap = getMap();
mMap.clear();
Expand All @@ -129,12 +127,14 @@ private LatLngBounds getBounds(List<LatLng> pointsList) {
}

public double getMapRotation() {
GoogleMap map = getMap();
if (map != null) {
return map.getCameraPosition().bearing;
if (isMapLayoutFinished()) {
return mMap.getCameraPosition().bearing;
} else {
return 0;
}
}

private boolean isMapLayoutFinished() {
return getMap() != null;
}
}

0 comments on commit 7f5b45e

Please sign in to comment.