react-native-maps 2.0.0-beta.6 → 2.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,8 +20,6 @@ import com.facebook.react.uimanager.events.RCTEventEmitter;
20
20
  import com.google.android.gms.location.Priority;
21
21
  import com.google.android.gms.maps.GoogleMap;
22
22
  import com.google.android.gms.maps.GoogleMapOptions;
23
- import com.google.android.gms.maps.model.LatLng;
24
- import com.google.android.gms.maps.model.LatLngBounds;
25
23
 
26
24
  import java.util.Map;
27
25
 
@@ -278,12 +276,6 @@ public class MapManager extends ViewGroupManager<MapView> {
278
276
 
279
277
  @Override
280
278
  public void receiveCommand(@NonNull MapView view, String commandId, @Nullable ReadableArray args) {
281
- int duration;
282
- double lat;
283
- double lng;
284
- double lngDelta;
285
- double latDelta;
286
- ReadableMap region;
287
279
  ReadableMap camera;
288
280
 
289
281
  switch (commandId) {
@@ -295,53 +287,6 @@ public class MapManager extends ViewGroupManager<MapView> {
295
287
  view.animateToCamera(camera, 0);
296
288
  break;
297
289
 
298
- case "animateCamera":
299
- if(args == null) {
300
- break;
301
- }
302
- camera = args.getMap(0);
303
- duration = args.getInt(1);
304
- view.animateToCamera(camera, duration);
305
- break;
306
-
307
- case "animateToRegion":
308
- if(args == null) {
309
- break;
310
- }
311
- region = args.getMap(0);
312
- duration = args.getInt(1);
313
- lng = region.getDouble("longitude");
314
- lat = region.getDouble("latitude");
315
- lngDelta = region.getDouble("longitudeDelta");
316
- latDelta = region.getDouble("latitudeDelta");
317
- LatLngBounds bounds = new LatLngBounds(
318
- new LatLng(lat - latDelta / 2, lng - lngDelta / 2), // southwest
319
- new LatLng(lat + latDelta / 2, lng + lngDelta / 2) // northeast
320
- );
321
- view.animateToRegion(bounds, duration);
322
- break;
323
-
324
- case "fitToElements":
325
- if(args == null) {
326
- break;
327
- }
328
- view.fitToElements(args.getMap(0), args.getBoolean(1));
329
- break;
330
-
331
- case "fitToSuppliedMarkers":
332
- if(args == null) {
333
- break;
334
- }
335
- view.fitToSuppliedMarkers(args.getArray(0), args.getMap(1), args.getBoolean(2));
336
- break;
337
-
338
- case "fitToCoordinates":
339
- if(args == null) {
340
- break;
341
- }
342
- view.fitToCoordinates(args.getArray(0), args.getMap(1), args.getBoolean(2));
343
- break;
344
-
345
290
  case "setMapBoundaries":
346
291
  if(args == null) {
347
292
  break;
@@ -93,7 +93,7 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
93
93
  private Boolean isMapLoaded = false;
94
94
  private Integer loadingBackgroundColor = null;
95
95
  private Integer loadingIndicatorColor = null;
96
- private final int baseMapPadding = 50;
96
+ public final int baseMapPadding = 50;
97
97
 
98
98
  private LatLngBounds boundsToMove;
99
99
  private CameraUpdate cameraToSet;
@@ -114,7 +114,7 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
114
114
  private static final String[] PERMISSIONS = new String[]{
115
115
  "android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION"};
116
116
 
117
- private final List<MapFeature> features = new ArrayList<>();
117
+ public final List<MapFeature> features = new ArrayList<>();
118
118
  private final Map<Marker, MapMarker> markerMap = new HashMap<>();
119
119
  private final Map<Polyline, MapPolyline> polylineMap = new HashMap<>();
120
120
  private final Map<Polygon, MapPolygon> polygonMap = new HashMap<>();
@@ -831,8 +831,7 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
831
831
  }
832
832
  }
833
833
 
834
- public void animateToCamera(ReadableMap camera, int duration) {
835
- if (map == null) return;
834
+ public CameraUpdate buildCameraUpdate(ReadableMap camera) {
836
835
  CameraPosition.Builder builder = new CameraPosition.Builder(map.getCameraPosition());
837
836
  if (camera.hasKey("zoom")) {
838
837
  builder.zoom((float)camera.getDouble("zoom"));
@@ -848,103 +847,26 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
848
847
  builder.target(new LatLng(center.getDouble("latitude"), center.getDouble("longitude")));
849
848
  }
850
849
 
851
- CameraUpdate update = CameraUpdateFactory.newCameraPosition(builder.build());
852
-
853
- if (duration <= 0) {
854
- map.moveCamera(update);
855
- }
856
- else {
857
- map.animateCamera(update, duration, null);
858
- }
859
- }
860
-
861
- public void animateToRegion(LatLngBounds bounds, int duration) {
862
- if (map == null) return;
863
- if(duration <= 0) {
864
- map.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0));
865
- } else {
866
- map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0), duration, null);
867
- }
850
+ return CameraUpdateFactory.newCameraPosition(builder.build());
868
851
  }
869
852
 
870
- public void fitToElements(ReadableMap edgePadding, boolean animated) {
853
+ public void animateToCamera(ReadableMap camera, int duration) {
871
854
  if (map == null) return;
872
855
 
873
- LatLngBounds.Builder builder = new LatLngBounds.Builder();
874
-
875
- boolean addedPosition = false;
876
-
877
- for (MapFeature feature : features) {
878
- if (feature instanceof MapMarker) {
879
- Marker marker = (Marker) feature.getFeature();
880
- builder.include(marker.getPosition());
881
- addedPosition = true;
882
- }
883
- // TODO(lmr): may want to include shapes / etc.
884
- }
885
- if (addedPosition) {
886
- LatLngBounds bounds = builder.build();
887
- CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, baseMapPadding);
888
-
889
- if (edgePadding != null) {
890
- map.setPadding(edgePadding.getInt("left"), edgePadding.getInt("top"),
891
- edgePadding.getInt("right"), edgePadding.getInt("bottom"));
892
- }
893
-
894
- if (animated) {
895
- map.animateCamera(cu);
896
- } else {
897
- map.moveCamera(cu);
898
- }
899
- }
900
- }
901
-
902
- public void fitToSuppliedMarkers(ReadableArray markerIDsArray, ReadableMap edgePadding, boolean animated) {
903
- if (map == null) return;
856
+ CameraUpdate update = buildCameraUpdate(camera);
904
857
 
905
- LatLngBounds.Builder builder = new LatLngBounds.Builder();
906
-
907
- String[] markerIDs = new String[markerIDsArray.size()];
908
- for (int i = 0; i < markerIDsArray.size(); i++) {
909
- markerIDs[i] = markerIDsArray.getString(i);
910
- }
911
-
912
- boolean addedPosition = false;
913
-
914
- List<String> markerIDList = Arrays.asList(markerIDs);
915
-
916
- for (MapFeature feature : features) {
917
- if (feature instanceof MapMarker) {
918
- String identifier = ((MapMarker) feature).getIdentifier();
919
- Marker marker = (Marker) feature.getFeature();
920
- if (markerIDList.contains(identifier)) {
921
- builder.include(marker.getPosition());
922
- addedPosition = true;
923
- }
924
- }
858
+ if (duration <= 0) {
859
+ map.moveCamera(update);
925
860
  }
926
-
927
- if (addedPosition) {
928
- LatLngBounds bounds = builder.build();
929
- CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, baseMapPadding);
930
-
931
- if (edgePadding != null) {
932
- map.setPadding(edgePadding.getInt("left"), edgePadding.getInt("top"),
933
- edgePadding.getInt("right"), edgePadding.getInt("bottom"));
934
- }
935
-
936
- if (animated) {
937
- map.animateCamera(cu);
938
- } else {
939
- map.moveCamera(cu);
940
- }
861
+ else {
862
+ map.animateCamera(update, duration, null);
941
863
  }
942
864
  }
943
865
 
944
- int baseLeftMapPadding;
945
- int baseRightMapPadding;
946
- int baseTopMapPadding;
947
- int baseBottomMapPadding;
866
+ public int baseLeftMapPadding;
867
+ public int baseRightMapPadding;
868
+ public int baseTopMapPadding;
869
+ public int baseBottomMapPadding;
948
870
 
949
871
  public void applyBaseMapPadding(int left, int top, int right, int bottom){
950
872
  this.map.setPadding(left, top, right, bottom);
@@ -954,36 +876,7 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
954
876
  baseBottomMapPadding = bottom;
955
877
  }
956
878
 
957
- public void fitToCoordinates(ReadableArray coordinatesArray, ReadableMap edgePadding,
958
- boolean animated) {
959
- if (map == null) return;
960
-
961
- LatLngBounds.Builder builder = new LatLngBounds.Builder();
962
-
963
- for (int i = 0; i < coordinatesArray.size(); i++) {
964
- ReadableMap latLng = coordinatesArray.getMap(i);
965
- double lat = latLng.getDouble("latitude");
966
- double lng = latLng.getDouble("longitude");
967
- builder.include(new LatLng(lat, lng));
968
- }
969
-
970
- LatLngBounds bounds = builder.build();
971
- CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, baseMapPadding);
972
-
973
- if (edgePadding != null) {
974
- appendMapPadding(edgePadding.getInt("left"), edgePadding.getInt("top"), edgePadding.getInt("right"), edgePadding.getInt("bottom"));
975
- }
976
-
977
- if (animated) {
978
- map.animateCamera(cu);
979
- } else {
980
- map.moveCamera(cu);
981
- }
982
- // Move the google logo to the default base padding value.
983
- map.setPadding(baseLeftMapPadding, baseTopMapPadding, baseRightMapPadding, baseBottomMapPadding);
984
- }
985
-
986
- private void appendMapPadding(int iLeft,int iTop, int iRight, int iBottom) {
879
+ public void appendMapPadding(int iLeft,int iTop, int iRight, int iBottom) {
987
880
  int left;
988
881
  int top;
989
882
  int right;