From 2751bdac1c035fe7a90e10c56289832b819e036a Mon Sep 17 00:00:00 2001 From: mar-v-in Date: Sat, 28 Jun 2014 20:50:00 +0200 Subject: [PATCH] Handle GoogleMapOptions fixes several wrong positioned maps bugs --- .../android/gms/maps/GoogleMapOptions.java | 34 ++++++++++++++++++- src/org/microg/gms/maps/GoogleMapImpl.java | 21 +++++++++--- 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/src/com/google/android/gms/maps/GoogleMapOptions.java b/src/com/google/android/gms/maps/GoogleMapOptions.java index 0c91e4e8..cdb64a71 100644 --- a/src/com/google/android/gms/maps/GoogleMapOptions.java +++ b/src/com/google/android/gms/maps/GoogleMapOptions.java @@ -108,7 +108,39 @@ public class GoogleMapOptions implements SafeParcelable { } } - public static Creator CREATOR = new Creator() { + public int getMapType() { + return mapType; + } + + public CameraPosition getCamera() { + return camera; + } + + public boolean isZoomControlsEnabled() { + return zoomControlsEnabled; + } + + public boolean isCompassEnabled() { + return compassEnabled; + } + + public boolean isScrollGesturesEnabled() { + return scrollGesturesEnabled; + } + + public boolean isZoomGesturesEnabled() { + return zoomGesturesEnabled; + } + + public boolean isTiltGesturesEnabled() { + return tiltGesturesEnabled; + } + + public boolean isRotateGesturesEnabled() { + return rotateGesturesEnabled; + } + + public static Creator CREATOR = new Creator() { public GoogleMapOptions createFromParcel(Parcel source) { return new GoogleMapOptions(source); } diff --git a/src/org/microg/gms/maps/GoogleMapImpl.java b/src/org/microg/gms/maps/GoogleMapImpl.java index 9cc74e79..425bdfb9 100644 --- a/src/org/microg/gms/maps/GoogleMapImpl.java +++ b/src/org/microg/gms/maps/GoogleMapImpl.java @@ -35,6 +35,7 @@ import com.google.android.gms.maps.model.internal.*; import com.google.android.maps.MapController; import com.google.android.maps.MapView; import org.microg.gms.maps.camera.CameraUpdate; +import org.microg.gms.maps.camera.CameraUpdateFactoryImpl; import org.microg.gms.maps.markup.*; public class GoogleMapImpl { @@ -49,6 +50,7 @@ public class GoogleMapImpl { private final ViewGroup view; private final GoogleMapOptions options; private final Delegate delegate = new Delegate(); + private final UiSettings uiSettings = new UiSettings(); private final Projection projection = new Projection(); private MapView mapView; private int mapType = 1; @@ -63,11 +65,22 @@ public class GoogleMapImpl { } catch (Exception e) { Log.d(TAG, "Sorry, can't create legacy MapView"); } - this.options = options; - } + this.options = options; + } public void onCreate(Bundle savedInstanceState) { - + try { + delegate.animateCamera(new CameraUpdateFactoryImpl().newCameraPosition(options.getCamera())); + delegate.setMapType(options.getMapType()); + uiSettings.setCompassEnabled(options.isCompassEnabled()); + uiSettings.setZoomControlsEnabled(options.isZoomControlsEnabled()); + uiSettings.setRotateGesturesEnabled(options.isRotateGesturesEnabled()); + uiSettings.setScrollGesturesEnabled(options.isScrollGesturesEnabled()); + uiSettings.setTiltGesturesEnabled(options.isTiltGesturesEnabled()); + uiSettings.setZoomGesturesEnabled(options.isZoomGesturesEnabled()); + } catch (RemoteException ignored) { + // It's not remote... + } } public IOnMarkerClickListener getMarkerClickListener() { @@ -242,7 +255,7 @@ public class GoogleMapImpl { @Override public IUiSettingsDelegate getUiSettings() throws RemoteException { - return new UiSettings(); + return uiSettings; } @Override