summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationContainer.java87
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationManager.java519
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Annotations.java25
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java244
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java204
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/FocalPointChangeListener.java11
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/IconManager.java155
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Image.java22
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/InfoWindowManager.java96
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapChangeReceiver.java395
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java241
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java1140
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java271
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java1350
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java2425
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java1283
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MarkerContainer.java146
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Markers.java27
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMap.java274
-rwxr-xr-xplatform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java1512
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/OnMapReadyCallback.java22
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/PolygonContainer.java84
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Polygons.java22
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/PolylineContainer.java83
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Polylines.java22
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java283
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/ShapeAnnotationContainer.java41
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/ShapeAnnotations.java13
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Style.java1150
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/SupportMapFragment.java219
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TelemetryDefinition.java66
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java341
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java1103
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/package-info.java4
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java158
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRendererRunnable.java32
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRendererScheduler.java17
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/EGLConfigChooser.java328
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/EGLConfigException.java21
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/package-info.java4
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/GLSurfaceViewMapRenderer.java115
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/MapboxGLSurfaceView.java54
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/package-info.java4
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/package-info.java4
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewMapRenderer.java115
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewRenderThread.java470
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/package-info.java4
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java179
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/package-info.java4
49 files changed, 0 insertions, 15389 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationContainer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationContainer.java
deleted file mode 100644
index e5bf512791..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationContainer.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-
-import android.support.annotation.NonNull;
-import android.support.v4.util.LongSparseArray;
-
-import com.mapbox.mapboxsdk.annotations.Annotation;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Encapsulates {@link Annotation}'s functionality..
- */
-class AnnotationContainer implements Annotations {
-
- private final NativeMap nativeMap;
- private final LongSparseArray<Annotation> annotations;
-
- AnnotationContainer(NativeMap nativeMap, LongSparseArray<Annotation> annotations) {
- this.nativeMap = nativeMap;
- this.annotations = annotations;
- }
-
- @Override
- public Annotation obtainBy(long id) {
- return annotations.get(id);
- }
-
- @NonNull
- @Override
- public List<Annotation> obtainAll() {
- List<Annotation> annotations = new ArrayList<>();
- for (int i = 0; i < this.annotations.size(); i++) {
- annotations.add(this.annotations.get(this.annotations.keyAt(i)));
- }
- return annotations;
- }
-
- @Override
- public void removeBy(long id) {
- if (nativeMap != null) {
- nativeMap.removeAnnotation(id);
- }
- annotations.remove(id);
- }
-
- @Override
- public void removeBy(@NonNull Annotation annotation) {
- long id = annotation.getId();
- removeBy(id);
- }
-
- @Override
- public void removeBy(@NonNull List<? extends Annotation> annotationList) {
- int count = annotationList.size();
- long[] ids = new long[count];
- for (int i = 0; i < count; i++) {
- ids[i] = annotationList.get(i).getId();
- }
-
- removeNativeAnnotations(ids);
-
- for (long id : ids) {
- annotations.remove(id);
- }
- }
-
- @Override
- public void removeAll() {
- int count = annotations.size();
- long[] ids = new long[count];
- for (int i = 0; i < count; i++) {
- ids[i] = annotations.keyAt(i);
- }
-
- removeNativeAnnotations(ids);
-
- annotations.clear();
- }
-
- private void removeNativeAnnotations(long[] ids) {
- if (nativeMap != null) {
- nativeMap.removeAnnotations(ids);
- }
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationManager.java
deleted file mode 100644
index 8875e7164b..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AnnotationManager.java
+++ /dev/null
@@ -1,519 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.graphics.Bitmap;
-import android.graphics.PointF;
-import android.graphics.Rect;
-import android.graphics.RectF;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v4.util.LongSparseArray;
-import android.view.View;
-import com.mapbox.mapboxsdk.Mapbox;
-import com.mapbox.mapboxsdk.R;
-import com.mapbox.mapboxsdk.annotations.Annotation;
-import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
-import com.mapbox.mapboxsdk.annotations.Marker;
-import com.mapbox.mapboxsdk.annotations.Polygon;
-import com.mapbox.mapboxsdk.annotations.PolygonOptions;
-import com.mapbox.mapboxsdk.annotations.Polyline;
-import com.mapbox.mapboxsdk.annotations.PolylineOptions;
-import com.mapbox.mapboxsdk.log.Logger;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Responsible for managing and tracking state of Annotations linked to Map. All events related to
- * annotations that occur on {@link MapboxMap} are forwarded to this class.
- * <p>
- * Responsible for referencing {@link InfoWindowManager}.
- * </p>
- * <p>
- * Exposes convenience methods to add/remove/update all subtypes of annotations found in
- * com.mapbox.mapboxsdk.annotations.
- * </p>
- */
-class AnnotationManager {
-
- private static final String TAG = "Mbgl-AnnotationManager";
-
- private static final long NO_ANNOTATION_ID = -1;
-
- @NonNull
- private final MapView mapView;
- private final IconManager iconManager;
- private final InfoWindowManager infoWindowManager = new InfoWindowManager();
- private final LongSparseArray<Annotation> annotationsArray;
- private final List<Marker> selectedMarkers = new ArrayList<>();
-
- private MapboxMap mapboxMap;
- @Nullable
- private MapboxMap.OnMarkerClickListener onMarkerClickListener;
- @Nullable
- private MapboxMap.OnPolygonClickListener onPolygonClickListener;
- @Nullable
- private MapboxMap.OnPolylineClickListener onPolylineClickListener;
-
- private Annotations annotations;
- private ShapeAnnotations shapeAnnotations;
- private Markers markers;
- private Polygons polygons;
- private Polylines polylines;
-
- AnnotationManager(@NonNull MapView mapView, LongSparseArray<Annotation> annotationsArray,
- IconManager iconManager, Annotations annotations, Markers markers, Polygons polygons,
- Polylines polylines, ShapeAnnotations shapeAnnotations) {
- this.mapView = mapView;
- this.annotationsArray = annotationsArray;
- this.iconManager = iconManager;
- this.annotations = annotations;
- this.markers = markers;
- this.polygons = polygons;
- this.polylines = polylines;
- this.shapeAnnotations = shapeAnnotations;
- }
-
- // TODO refactor MapboxMap out for Projection and Transform
- // Requires removing MapboxMap from Annotations by using Peer model from #6912
- @NonNull
- AnnotationManager bind(MapboxMap mapboxMap) {
- this.mapboxMap = mapboxMap;
- return this;
- }
-
- void update() {
- infoWindowManager.update();
- }
-
- //
- // Annotations
- //
-
- Annotation getAnnotation(long id) {
- return annotations.obtainBy(id);
- }
-
- List<Annotation> getAnnotations() {
- return annotations.obtainAll();
- }
-
- void removeAnnotation(long id) {
- annotations.removeBy(id);
- }
-
- void removeAnnotation(@NonNull Annotation annotation) {
- if (annotation instanceof Marker) {
- Marker marker = (Marker) annotation;
- marker.hideInfoWindow();
- if (selectedMarkers.contains(marker)) {
- selectedMarkers.remove(marker);
- }
- // do icon cleanup
- iconManager.iconCleanup(marker.getIcon());
- }
- annotations.removeBy(annotation);
- }
-
- void removeAnnotations(@NonNull List<? extends Annotation> annotationList) {
- for (Annotation annotation : annotationList) {
- if (annotation instanceof Marker) {
- Marker marker = (Marker) annotation;
- marker.hideInfoWindow();
- if (selectedMarkers.contains(marker)) {
- selectedMarkers.remove(marker);
- }
- iconManager.iconCleanup(marker.getIcon());
- }
- }
- annotations.removeBy(annotationList);
- }
-
- void removeAnnotations() {
- Annotation annotation;
- int count = annotationsArray.size();
- long[] ids = new long[count];
- selectedMarkers.clear();
- for (int i = 0; i < count; i++) {
- ids[i] = annotationsArray.keyAt(i);
- annotation = annotationsArray.get(ids[i]);
- if (annotation instanceof Marker) {
- Marker marker = (Marker) annotation;
- marker.hideInfoWindow();
- iconManager.iconCleanup(marker.getIcon());
- }
- }
- annotations.removeAll();
- }
-
- //
- // Markers
- //
-
- Marker addMarker(@NonNull BaseMarkerOptions markerOptions, @NonNull MapboxMap mapboxMap) {
- return markers.addBy(markerOptions, mapboxMap);
- }
-
- List<Marker> addMarkers(@NonNull List<? extends BaseMarkerOptions> markerOptionsList, @NonNull MapboxMap mapboxMap) {
- return markers.addBy(markerOptionsList, mapboxMap);
- }
-
- void updateMarker(@NonNull Marker updatedMarker, @NonNull MapboxMap mapboxMap) {
- if (!isAddedToMap(updatedMarker)) {
- logNonAdded(updatedMarker);
- return;
- }
- markers.update(updatedMarker, mapboxMap);
- }
-
- List<Marker> getMarkers() {
- return markers.obtainAll();
- }
-
- @NonNull
- List<Marker> getMarkersInRect(@NonNull RectF rectangle) {
- return markers.obtainAllIn(rectangle);
- }
-
- void reloadMarkers() {
- markers.reload();
- }
-
- //
- // Polygons
- //
-
- Polygon addPolygon(@NonNull PolygonOptions polygonOptions, @NonNull MapboxMap mapboxMap) {
- return polygons.addBy(polygonOptions, mapboxMap);
- }
-
- List<Polygon> addPolygons(@NonNull List<PolygonOptions> polygonOptionsList, @NonNull MapboxMap mapboxMap) {
- return polygons.addBy(polygonOptionsList, mapboxMap);
- }
-
- void updatePolygon(@NonNull Polygon polygon) {
- if (!isAddedToMap(polygon)) {
- logNonAdded(polygon);
- return;
- }
- polygons.update(polygon);
- }
-
- List<Polygon> getPolygons() {
- return polygons.obtainAll();
- }
-
- //
- // Polylines
- //
-
- Polyline addPolyline(@NonNull PolylineOptions polylineOptions, @NonNull MapboxMap mapboxMap) {
- return polylines.addBy(polylineOptions, mapboxMap);
- }
-
- List<Polyline> addPolylines(@NonNull List<PolylineOptions> polylineOptionsList, @NonNull MapboxMap mapboxMap) {
- return polylines.addBy(polylineOptionsList, mapboxMap);
- }
-
- void updatePolyline(@NonNull Polyline polyline) {
- if (!isAddedToMap(polyline)) {
- logNonAdded(polyline);
- return;
- }
- polylines.update(polyline);
- }
-
- List<Polyline> getPolylines() {
- return polylines.obtainAll();
- }
-
- // TODO Refactor from here still in progress
- void setOnMarkerClickListener(@Nullable MapboxMap.OnMarkerClickListener listener) {
- onMarkerClickListener = listener;
- }
-
- void setOnPolygonClickListener(@Nullable MapboxMap.OnPolygonClickListener listener) {
- onPolygonClickListener = listener;
- }
-
- void setOnPolylineClickListener(@Nullable MapboxMap.OnPolylineClickListener listener) {
- onPolylineClickListener = listener;
- }
-
- void selectMarker(@NonNull Marker marker) {
- if (selectedMarkers.contains(marker)) {
- return;
- }
-
- // Need to deselect any currently selected annotation first
- if (!infoWindowManager.isAllowConcurrentMultipleOpenInfoWindows()) {
- deselectMarkers();
- }
-
- if (infoWindowManager.isInfoWindowValidForMarker(marker) || infoWindowManager.getInfoWindowAdapter() != null) {
- infoWindowManager.add(marker.showInfoWindow(mapboxMap, mapView));
- }
-
- // only add to selected markers if user didn't handle the click event themselves #3176
- selectedMarkers.add(marker);
- }
-
- void deselectMarkers() {
- if (selectedMarkers.isEmpty()) {
- return;
- }
-
- for (Marker marker : selectedMarkers) {
- if (marker != null) {
- if (marker.isInfoWindowShown()) {
- marker.hideInfoWindow();
- }
- }
- }
-
- // Removes all selected markers from the list
- selectedMarkers.clear();
- }
-
- void deselectMarker(@NonNull Marker marker) {
- if (!selectedMarkers.contains(marker)) {
- return;
- }
-
- if (marker.isInfoWindowShown()) {
- marker.hideInfoWindow();
- }
- selectedMarkers.remove(marker);
- }
-
- @NonNull
- List<Marker> getSelectedMarkers() {
- return selectedMarkers;
- }
-
- @NonNull
- InfoWindowManager getInfoWindowManager() {
- return infoWindowManager;
- }
-
- void adjustTopOffsetPixels(@NonNull MapboxMap mapboxMap) {
- int count = annotationsArray.size();
- for (int i = 0; i < count; i++) {
- Annotation annotation = annotationsArray.get(i);
- if (annotation instanceof Marker) {
- Marker marker = (Marker) annotation;
- marker.setTopOffsetPixels(
- iconManager.getTopOffsetPixelsForIcon(marker.getIcon()));
- }
- }
-
- for (Marker marker : selectedMarkers) {
- if (marker.isInfoWindowShown()) {
- marker.hideInfoWindow();
- marker.showInfoWindow(mapboxMap, mapView);
- }
- }
- }
-
- private boolean isAddedToMap(@Nullable Annotation annotation) {
- return annotation != null && annotation.getId() != -1 && annotationsArray.indexOfKey(annotation.getId()) > -1;
- }
-
- private void logNonAdded(@NonNull Annotation annotation) {
- Logger.w(TAG, String.format(
- "Attempting to update non-added %s with value %s", annotation.getClass().getCanonicalName(), annotation)
- );
- }
-
- //
- // Click event
- //
-
- boolean onTap(@NonNull PointF tapPoint) {
- MarkerHit markerHit = getMarkerHitFromTouchArea(tapPoint);
- long markerId = new MarkerHitResolver(mapboxMap).execute(markerHit);
- if (markerId != NO_ANNOTATION_ID) {
- if (isClickHandledForMarker(markerId)) {
- return true;
- }
- }
-
- ShapeAnnotationHit shapeAnnotationHit = getShapeAnnotationHitFromTap(tapPoint);
- Annotation annotation = new ShapeAnnotationHitResolver(shapeAnnotations).execute(shapeAnnotationHit);
- return annotation != null && handleClickForShapeAnnotation(annotation);
- }
-
- private ShapeAnnotationHit getShapeAnnotationHitFromTap(PointF tapPoint) {
- float touchTargetSide = Mapbox.getApplicationContext().getResources().getDimension(R.dimen.mapbox_eight_dp);
- RectF tapRect = new RectF(
- tapPoint.x - touchTargetSide,
- tapPoint.y - touchTargetSide,
- tapPoint.x + touchTargetSide,
- tapPoint.y + touchTargetSide
- );
- return new ShapeAnnotationHit(tapRect);
- }
-
- private boolean handleClickForShapeAnnotation(Annotation annotation) {
- if (annotation instanceof Polygon && onPolygonClickListener != null) {
- onPolygonClickListener.onPolygonClick((Polygon) annotation);
- return true;
- } else if (annotation instanceof Polyline && onPolylineClickListener != null) {
- onPolylineClickListener.onPolylineClick((Polyline) annotation);
- return true;
- }
- return false;
- }
-
- private MarkerHit getMarkerHitFromTouchArea(PointF tapPoint) {
- int touchSurfaceWidth = (int) (iconManager.getHighestIconHeight() * 1.5);
- int touchSurfaceHeight = (int) (iconManager.getHighestIconWidth() * 1.5);
- final RectF tapRect = new RectF(tapPoint.x - touchSurfaceWidth,
- tapPoint.y - touchSurfaceHeight,
- tapPoint.x + touchSurfaceWidth,
- tapPoint.y + touchSurfaceHeight
- );
- return new MarkerHit(tapRect, getMarkersInRect(tapRect));
- }
-
- private boolean isClickHandledForMarker(long markerId) {
- Marker marker = (Marker) getAnnotation(markerId);
- boolean handledDefaultClick = onClickMarker(marker);
- if (!handledDefaultClick) {
- toggleMarkerSelectionState(marker);
- }
- return true;
- }
-
- private boolean onClickMarker(@NonNull Marker marker) {
- return onMarkerClickListener != null && onMarkerClickListener.onMarkerClick(marker);
- }
-
- private void toggleMarkerSelectionState(@NonNull Marker marker) {
- if (!selectedMarkers.contains(marker)) {
- selectMarker(marker);
- } else {
- deselectMarker(marker);
- }
- }
-
- private static class ShapeAnnotationHitResolver {
-
- private ShapeAnnotations shapeAnnotations;
-
- ShapeAnnotationHitResolver(ShapeAnnotations shapeAnnotations) {
- this.shapeAnnotations = shapeAnnotations;
- }
-
- @Nullable
- public Annotation execute(@NonNull ShapeAnnotationHit shapeHit) {
- Annotation foundAnnotation = null;
- List<Annotation> annotations = shapeAnnotations.obtainAllIn(shapeHit.tapPoint);
- if (annotations.size() > 0) {
- foundAnnotation = annotations.get(0);
- }
- return foundAnnotation;
- }
- }
-
- private static class MarkerHitResolver {
-
- @NonNull
- private final Projection projection;
- private final int minimalTouchSize;
-
- @Nullable
- private View view;
-
- private Bitmap bitmap;
- private int bitmapWidth;
- private int bitmapHeight;
- private PointF markerLocation;
-
- @NonNull
- private Rect hitRectView = new Rect();
- @NonNull
- private RectF hitRectMarker = new RectF();
- @NonNull
- private RectF highestSurfaceIntersection = new RectF();
-
- private long closestMarkerId = NO_ANNOTATION_ID;
-
- MarkerHitResolver(@NonNull MapboxMap mapboxMap) {
- this.projection = mapboxMap.getProjection();
- this.minimalTouchSize = (int) (32 * Mapbox.getApplicationContext().getResources().getDisplayMetrics().density);
- }
-
- public long execute(@NonNull MarkerHit markerHit) {
- resolveForMarkers(markerHit);
- return closestMarkerId;
- }
-
- private void resolveForMarkers(MarkerHit markerHit) {
- for (Marker marker : markerHit.markers) {
- resolveForMarker(markerHit, marker);
- }
- }
-
- private void resolveForMarker(@NonNull MarkerHit markerHit, Marker marker) {
- markerLocation = projection.toScreenLocation(marker.getPosition());
- bitmap = marker.getIcon().getBitmap();
-
- bitmapHeight = bitmap.getHeight();
- if (bitmapHeight < minimalTouchSize) {
- bitmapHeight = minimalTouchSize;
- }
-
- bitmapWidth = bitmap.getWidth();
- if (bitmapWidth < minimalTouchSize) {
- bitmapWidth = minimalTouchSize;
- }
-
- hitRectMarker.set(0, 0, bitmapWidth, bitmapHeight);
- hitRectMarker.offsetTo(
- markerLocation.x - bitmapWidth / 2,
- markerLocation.y - bitmapHeight / 2
- );
- hitTestMarker(markerHit, marker, hitRectMarker);
- }
-
- private void hitTestMarker(MarkerHit markerHit, @NonNull Marker marker, RectF hitRectMarker) {
- if (hitRectMarker.contains(markerHit.getTapPointX(), markerHit.getTapPointY())) {
- hitRectMarker.intersect(markerHit.tapRect);
- if (isRectangleHighestSurfaceIntersection(hitRectMarker)) {
- highestSurfaceIntersection = new RectF(hitRectMarker);
- closestMarkerId = marker.getId();
- }
- }
- }
-
- private boolean isRectangleHighestSurfaceIntersection(RectF rectF) {
- return rectF.width() * rectF.height() > highestSurfaceIntersection.width() * highestSurfaceIntersection.height();
- }
- }
-
- private static class ShapeAnnotationHit {
- private final RectF tapPoint;
-
- ShapeAnnotationHit(RectF tapPoint) {
- this.tapPoint = tapPoint;
- }
- }
-
- private static class MarkerHit {
- private final RectF tapRect;
- private final List<Marker> markers;
-
- MarkerHit(RectF tapRect, List<Marker> markers) {
- this.tapRect = tapRect;
- this.markers = markers;
- }
-
- float getTapPointX() {
- return tapRect.centerX();
- }
-
- float getTapPointY() {
- return tapRect.centerY();
- }
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Annotations.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Annotations.java
deleted file mode 100644
index ae41cbb0cb..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Annotations.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-
-import android.support.annotation.NonNull;
-
-import com.mapbox.mapboxsdk.annotations.Annotation;
-
-import java.util.List;
-
-/**
- * Interface that defines convenient methods for working with a {@link Annotation}'s collection.
- */
-interface Annotations {
- Annotation obtainBy(long id);
-
- List<Annotation> obtainAll();
-
- void removeBy(long id);
-
- void removeBy(@NonNull Annotation annotation);
-
- void removeBy(@NonNull List<? extends Annotation> annotationList);
-
- void removeAll();
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java
deleted file mode 100644
index 5384a29fca..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java
+++ /dev/null
@@ -1,244 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.ActivityNotFoundException;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.net.Uri;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.view.View;
-import android.widget.ArrayAdapter;
-import android.widget.Toast;
-import com.mapbox.mapboxsdk.MapStrictMode;
-import com.mapbox.mapboxsdk.Mapbox;
-import com.mapbox.mapboxsdk.R;
-import com.mapbox.mapboxsdk.attribution.Attribution;
-import com.mapbox.mapboxsdk.attribution.AttributionParser;
-import com.mapbox.mapboxsdk.camera.CameraPosition;
-import com.mapbox.mapboxsdk.style.sources.Source;
-
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Locale;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Responsible for managing attribution interactions on the map.
- * <p>
- * When the user clicks the attribution icon, {@link AttributionDialogManager#onClick(View)} will be invoked.
- * An attribution dialog will be shown to the user with contents based on the attributions found in the map style.
- * Additionally an telemetry option item is shown to configure telemetry settings.
- * </p>
- */
-public class AttributionDialogManager implements View.OnClickListener, DialogInterface.OnClickListener {
- private static final String MAP_FEEDBACK_URL = "https://apps.mapbox.com/feedback";
- private static final String MAP_FEEDBACK_URL_OLD = "https://www.mapbox.com/map-feedback";
- private static final String MAP_FEEDBACK_URL_LOCATION_FRAGMENT_FORMAT = "/%f/%f/%f/%f/%d";
- private static final String MAP_FEEDBACK_STYLE_URI_REGEX = "^(.*://[^:^/]*)/(.*)/(.*)";
-
- @NonNull
- private final Context context;
- @NonNull
- private final MapboxMap mapboxMap;
- private Set<Attribution> attributionSet;
- private AlertDialog dialog;
-
- public AttributionDialogManager(@NonNull Context context, @NonNull MapboxMap mapboxMap) {
- this.context = context;
- this.mapboxMap = mapboxMap;
- }
-
- // Called when someone presses the attribution icon on the map
- @Override
- public void onClick(@NonNull View view) {
- attributionSet = new AttributionBuilder(mapboxMap, view.getContext()).build();
-
- boolean isActivityFinishing = false;
- if (context instanceof Activity) {
- isActivityFinishing = ((Activity) context).isFinishing();
- }
-
- // check is hosting activity isn't finishing
- // https://github.com/mapbox/mapbox-gl-native/issues/11238
- if (!isActivityFinishing) {
- showAttributionDialog(getAttributionTitles());
- }
- }
-
- protected void showAttributionDialog(@NonNull String[] attributionTitles) {
- AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setTitle(R.string.mapbox_attributionsDialogTitle);
- builder.setAdapter(new ArrayAdapter<>(context, R.layout.mapbox_attribution_list_item, attributionTitles), this);
- dialog = builder.show();
- }
-
- private String[] getAttributionTitles() {
- List<String> titles = new ArrayList<>();
- for (Attribution attribution : attributionSet) {
- titles.add(attribution.getTitle());
- }
- return titles.toArray(new String[titles.size()]);
- }
-
- // Called when someone selects an attribution or telemetry settings from the dialog
- @Override
- public void onClick(DialogInterface dialog, int which) {
- if (isLatestEntry(which)) {
- showTelemetryDialog();
- } else {
- showMapAttributionWebPage(which);
- }
- }
-
- public void onStop() {
- if (dialog != null && dialog.isShowing()) {
- dialog.dismiss();
- }
- }
-
- private boolean isLatestEntry(int attributionKeyIndex) {
- return attributionKeyIndex == getAttributionTitles().length - 1;
- }
-
- private void showTelemetryDialog() {
- AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setTitle(R.string.mapbox_attributionTelemetryTitle);
- builder.setMessage(R.string.mapbox_attributionTelemetryMessage);
- builder.setPositiveButton(R.string.mapbox_attributionTelemetryPositive, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(@NonNull DialogInterface dialog, int which) {
- TelemetryDefinition telemetry = Mapbox.getTelemetry();
- if (telemetry != null) {
- telemetry.setUserTelemetryRequestState(true);
- }
- dialog.cancel();
- }
- });
- builder.setNeutralButton(R.string.mapbox_attributionTelemetryNeutral, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(@NonNull DialogInterface dialog, int which) {
- showWebPage(context.getResources().getString(R.string.mapbox_telemetryLink));
- dialog.cancel();
- }
- });
- builder.setNegativeButton(R.string.mapbox_attributionTelemetryNegative, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(@NonNull DialogInterface dialog, int which) {
- TelemetryDefinition telemetry = Mapbox.getTelemetry();
- if (telemetry != null) {
- telemetry.setUserTelemetryRequestState(false);
- }
- dialog.cancel();
- }
- });
- builder.show();
- }
-
- private void showMapAttributionWebPage(int which) {
- Attribution[] attributions = attributionSet.toArray(new Attribution[attributionSet.size()]);
- String url = attributions[which].getUrl();
- if (url.contains(MAP_FEEDBACK_URL_OLD) || url.contains(MAP_FEEDBACK_URL)) {
- url = buildMapFeedbackMapUrl(Mapbox.getAccessToken());
- }
- showWebPage(url);
- }
-
- @NonNull
- String buildMapFeedbackMapUrl(@Nullable String accessToken) {
- // TODO Add Android Maps SDK version to the query parameter, currently the version API is not available.
- // TODO Keep track of this issue at [#15632](https://github.com/mapbox/mapbox-gl-native/issues/15632)
-
- Uri.Builder builder = Uri.parse(MAP_FEEDBACK_URL).buildUpon();
-
- CameraPosition cameraPosition = mapboxMap.getCameraPosition();
- if (cameraPosition != null) {
- builder.encodedFragment(String.format(Locale.getDefault(), MAP_FEEDBACK_URL_LOCATION_FRAGMENT_FORMAT,
- cameraPosition.target.getLongitude(), cameraPosition.target.getLatitude(),
- cameraPosition.zoom, cameraPosition.bearing, (int) cameraPosition.tilt));
- }
-
- String packageName = context.getApplicationContext().getPackageName();
- if (packageName != null) {
- builder.appendQueryParameter("referrer", packageName);
- }
-
- if (accessToken != null) {
- builder.appendQueryParameter("access_token", accessToken);
- }
-
- Style style = mapboxMap.getStyle();
- if (style != null) {
- String styleUri = style.getUri();
- Pattern pattern = Pattern.compile(MAP_FEEDBACK_STYLE_URI_REGEX);
- Matcher matcher = pattern.matcher(styleUri);
-
- if (matcher.find()) {
- String styleOwner = matcher.group(2);
- String styleId = matcher.group(3);
-
- builder.appendQueryParameter("owner", styleOwner)
- .appendQueryParameter("id", styleId);
- }
- }
-
- return builder.build().toString();
- }
-
- private void showWebPage(@NonNull String url) {
- try {
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setData(Uri.parse(url));
- context.startActivity(intent);
- } catch (ActivityNotFoundException exception) {
- // explicitly handling if the device hasn't have a web browser installed. #8899
- Toast.makeText(context, R.string.mapbox_attributionErrorNoBrowser, Toast.LENGTH_LONG).show();
- MapStrictMode.strictModeViolation(exception);
- }
- }
-
- private static class AttributionBuilder {
-
- private final MapboxMap mapboxMap;
- @NonNull
- private final WeakReference<Context> context;
-
- AttributionBuilder(MapboxMap mapboxMap, Context context) {
- this.mapboxMap = mapboxMap;
- this.context = new WeakReference<>(context);
- }
-
- private Set<Attribution> build() {
- Context context = this.context.get();
- if (context == null) {
- return Collections.emptySet();
- }
-
- List<String> attributions = new ArrayList<>();
- String attribution;
-
- Style style = mapboxMap.getStyle();
- if (style != null) {
- for (Source source : style.getSources()) {
- attribution = source.getAttribution();
- if (!attribution.isEmpty()) {
- attributions.add(attribution);
- }
- }
- }
-
- return new AttributionParser.Options(context)
- .withCopyrightSign(true)
- .withImproveMap(true)
- .withTelemetryAttribution(true)
- .withAttributionData(attributions.toArray(new String[attributions.size()]))
- .build().getAttributions();
- }
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java
deleted file mode 100644
index a1fd4e7e3e..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java
+++ /dev/null
@@ -1,204 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.os.Handler;
-import android.os.Message;
-import android.support.annotation.IntDef;
-import android.support.annotation.NonNull;
-
-import java.lang.annotation.Retention;
-import java.lang.ref.WeakReference;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraIdleListener;
-import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveCanceledListener;
-import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveListener;
-import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener;
-import static java.lang.annotation.RetentionPolicy.SOURCE;
-
-/**
- * Class responsible for dispatching camera change events to registered listeners.
- */
-class CameraChangeDispatcher implements MapboxMap.OnCameraMoveStartedListener, MapboxMap.OnCameraMoveListener,
- MapboxMap.OnCameraMoveCanceledListener, OnCameraIdleListener {
-
- private final CameraChangeHandler handler = new CameraChangeHandler(this);
-
- private boolean idle = true;
- private int moveStartedReason;
-
- private final CopyOnWriteArrayList<OnCameraMoveStartedListener> onCameraMoveStarted = new CopyOnWriteArrayList<>();
- private final CopyOnWriteArrayList<OnCameraMoveCanceledListener> onCameraMoveCanceled = new CopyOnWriteArrayList<>();
- private final CopyOnWriteArrayList<OnCameraMoveListener> onCameraMove = new CopyOnWriteArrayList<>();
- private final CopyOnWriteArrayList<OnCameraIdleListener> onCameraIdle = new CopyOnWriteArrayList<>();
-
- @Retention(SOURCE)
- @IntDef( {MOVE_STARTED, MOVE, MOVE_CANCELED, IDLE})
- @interface CameraChange {
- }
-
- private static final int MOVE_STARTED = 0;
- private static final int MOVE = 1;
- private static final int MOVE_CANCELED = 2;
- private static final int IDLE = 3;
-
- @Override
- public void onCameraMoveStarted(final int reason) {
- moveStartedReason = reason;
- handler.scheduleMessage(MOVE_STARTED);
- }
-
- @Override
- public void onCameraMove() {
- handler.scheduleMessage(MOVE);
- }
-
- @Override
- public void onCameraMoveCanceled() {
- handler.scheduleMessage(MOVE_CANCELED);
- }
-
- @Override
- public void onCameraIdle() {
- handler.scheduleMessage(IDLE);
- }
-
- void addOnCameraIdleListener(@NonNull OnCameraIdleListener listener) {
- onCameraIdle.add(listener);
- }
-
- void removeOnCameraIdleListener(@NonNull OnCameraIdleListener listener) {
- if (onCameraIdle.contains(listener)) {
- onCameraIdle.remove(listener);
- }
- }
-
- void addOnCameraMoveCancelListener(OnCameraMoveCanceledListener listener) {
- onCameraMoveCanceled.add(listener);
- }
-
- void removeOnCameraMoveCancelListener(OnCameraMoveCanceledListener listener) {
- if (onCameraMoveCanceled.contains(listener)) {
- onCameraMoveCanceled.remove(listener);
- }
- }
-
- void addOnCameraMoveStartedListener(OnCameraMoveStartedListener listener) {
- onCameraMoveStarted.add(listener);
- }
-
- void removeOnCameraMoveStartedListener(OnCameraMoveStartedListener listener) {
- if (onCameraMoveStarted.contains(listener)) {
- onCameraMoveStarted.remove(listener);
- }
- }
-
- void addOnCameraMoveListener(OnCameraMoveListener listener) {
- onCameraMove.add(listener);
- }
-
- void removeOnCameraMoveListener(OnCameraMoveListener listener) {
- if (onCameraMove.contains(listener)) {
- onCameraMove.remove(listener);
- }
- }
-
- private void executeOnCameraMoveStarted() {
- if (!idle) {
- return;
- }
- idle = false;
- if (!onCameraMoveStarted.isEmpty()) {
- for (OnCameraMoveStartedListener cameraMoveStartedListener : onCameraMoveStarted) {
- cameraMoveStartedListener.onCameraMoveStarted(moveStartedReason);
- }
- }
- }
-
- private void executeOnCameraMove() {
- if (!onCameraMove.isEmpty() && !idle) {
- for (OnCameraMoveListener cameraMoveListener : onCameraMove) {
- cameraMoveListener.onCameraMove();
- }
- }
- }
-
- private void executeOnCameraMoveCancelled() {
- if (!onCameraMoveCanceled.isEmpty() && !idle) {
- for (OnCameraMoveCanceledListener cameraMoveCanceledListener : onCameraMoveCanceled) {
- cameraMoveCanceledListener.onCameraMoveCanceled();
- }
- }
- }
-
- private void executeOnCameraIdle() {
- if (idle) {
- return;
- }
- idle = true;
- if (!onCameraIdle.isEmpty()) {
- for (OnCameraIdleListener cameraIdleListener : onCameraIdle) {
- cameraIdleListener.onCameraIdle();
- }
- }
- }
-
- void onDestroy() {
- handler.removeCallbacksAndMessages(null);
- onCameraMoveStarted.clear();
- onCameraMoveCanceled.clear();
- onCameraMove.clear();
- onCameraIdle.clear();
- }
-
- private static class CameraChangeHandler extends Handler {
-
- private WeakReference<CameraChangeDispatcher> dispatcherWeakReference;
-
- CameraChangeHandler(CameraChangeDispatcher dispatcher) {
- super();
- this.dispatcherWeakReference = new WeakReference<>(dispatcher);
- }
-
- @Override
- public void handleMessage(@NonNull Message msg) {
- CameraChangeDispatcher dispatcher = dispatcherWeakReference.get();
- if (dispatcher != null) {
- switch (msg.what) {
- case MOVE_STARTED:
- dispatcher.executeOnCameraMoveStarted();
- break;
- case MOVE:
- dispatcher.executeOnCameraMove();
- break;
- case MOVE_CANCELED:
- dispatcher.executeOnCameraMoveCancelled();
- break;
- case IDLE:
- dispatcher.executeOnCameraIdle();
- break;
- }
- }
- }
-
- void scheduleMessage(@CameraChange int change) {
- CameraChangeDispatcher dispatcher = dispatcherWeakReference.get();
- if (dispatcher != null) {
- // if there is a movement that is cancelled/stopped and restarted in the same code block
- // we can safely assume that the movement will continue, no need for dispatching unnecessary callbacks sequence
- if (change == MOVE_STARTED) {
- boolean shouldReturn = !dispatcher.idle && (hasMessages(IDLE) || hasMessages(MOVE_CANCELED));
- removeMessages(IDLE);
- removeMessages(MOVE_CANCELED);
-
- if (shouldReturn) {
- return;
- }
- }
-
- Message message = new Message();
- message.what = change;
- this.sendMessage(message);
- }
- }
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/FocalPointChangeListener.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/FocalPointChangeListener.java
deleted file mode 100644
index aec9a848b7..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/FocalPointChangeListener.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.graphics.PointF;
-
-/**
- * Interface definition of a callback that is invoked when the focal point will change.
- */
-public interface FocalPointChangeListener {
-
- void onFocalPointChanged(PointF pointF);
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/IconManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/IconManager.java
deleted file mode 100644
index 3a0824ad11..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/IconManager.java
+++ /dev/null
@@ -1,155 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.graphics.Bitmap;
-
-import android.support.annotation.NonNull;
-import com.mapbox.mapboxsdk.Mapbox;
-import com.mapbox.mapboxsdk.annotations.Icon;
-import com.mapbox.mapboxsdk.annotations.IconFactory;
-import com.mapbox.mapboxsdk.annotations.Marker;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Responsible for managing icons added to the Map.
- * <p>
- * Maintains a {@link List} of {@link Icon} and is responsible for initialising default markers.
- * </p>
- * <p>
- * Keep track of icons added and the resulting average icon size. This is used internally by our
- * gestures detection to calculate the size of a touch target.
- * </p>
- */
-class IconManager {
-
- private final Map<Icon, Integer> iconMap = new HashMap<>();
-
- private NativeMap nativeMap;
- private int highestIconWidth;
- private int highestIconHeight;
-
- IconManager(NativeMap nativeMap) {
- this.nativeMap = nativeMap;
- }
-
- Icon loadIconForMarker(@NonNull Marker marker) {
- Icon icon = marker.getIcon();
- if (icon == null) {
- // TODO replace with anchor implementation, we are faking an anchor by adding extra pixels and diving height by 2
- icon = loadDefaultIconForMarker(marker);
- } else {
- updateHighestIconSize(icon);
- }
- addIcon(icon);
- return icon;
- }
-
- int getTopOffsetPixelsForIcon(@NonNull Icon icon) {
- return (int) (nativeMap.getTopOffsetPixelsForAnnotationSymbol(icon.getId()) * nativeMap.getPixelRatio());
- }
-
- int getHighestIconWidth() {
- return highestIconWidth;
- }
-
- int getHighestIconHeight() {
- return highestIconHeight;
- }
-
- private Icon loadDefaultIconForMarker(Marker marker) {
- Icon icon = IconFactory.getInstance(Mapbox.getApplicationContext()).defaultMarker();
- Bitmap bitmap = icon.getBitmap();
- updateHighestIconSize(bitmap.getWidth(), bitmap.getHeight() / 2);
- marker.setIcon(icon);
- return icon;
- }
-
- private void addIcon(@NonNull Icon icon) {
- addIcon(icon, true);
- }
-
- private void addIcon(@NonNull Icon icon, boolean addIconToMap) {
- if (!iconMap.keySet().contains(icon)) {
- iconMap.put(icon, 1);
- if (addIconToMap) {
- loadIcon(icon);
- }
- } else {
- iconMap.put(icon, iconMap.get(icon) + 1);
- }
- }
-
- private void updateHighestIconSize(Icon icon) {
- updateHighestIconSize(icon.getBitmap());
- }
-
- private void updateHighestIconSize(Bitmap bitmap) {
- updateHighestIconSize(bitmap.getWidth(), bitmap.getHeight());
- }
-
- private void updateHighestIconSize(int width, int height) {
- if (width > highestIconWidth) {
- highestIconWidth = width;
- }
-
- if (height > highestIconHeight) {
- highestIconHeight = height;
- }
- }
-
- private void loadIcon(Icon icon) {
- Bitmap bitmap = icon.getBitmap();
- nativeMap.addAnnotationIcon(icon.getId(),
- bitmap.getWidth(),
- bitmap.getHeight(),
- icon.getScale(),
- icon.toBytes());
- }
-
- void reloadIcons() {
- for (Icon icon : iconMap.keySet()) {
- loadIcon(icon);
- }
- }
-
- void ensureIconLoaded(@NonNull Marker marker, @NonNull MapboxMap mapboxMap) {
- Icon icon = marker.getIcon();
- if (icon == null) {
- icon = loadDefaultIconForMarker(marker);
- }
- addIcon(icon);
- setTopOffsetPixels(marker, mapboxMap, icon);
- }
-
- private void setTopOffsetPixels(Marker marker, @NonNull MapboxMap mapboxMap, @NonNull Icon icon) {
- // this seems to be a costly operation according to the profiler so I'm trying to save some calls
- Marker previousMarker = marker.getId() != -1 ? (Marker) mapboxMap.getAnnotation(marker.getId()) : null;
- if (previousMarker == null || previousMarker.getIcon() == null || previousMarker.getIcon() != marker.getIcon()) {
- marker.setTopOffsetPixels(getTopOffsetPixelsForIcon(icon));
- }
- }
-
- void iconCleanup(@NonNull Icon icon) {
- Integer refCounter = iconMap.get(icon);
- if (refCounter != null) {
- refCounter--;
- if (refCounter == 0) {
- remove(icon);
- } else {
- updateIconRefCounter(icon, refCounter);
- }
- }
- }
-
- private void remove(Icon icon) {
- nativeMap.removeAnnotationIcon(icon.getId());
- iconMap.remove(icon);
- }
-
- private void updateIconRefCounter(Icon icon, int refCounter) {
- iconMap.put(icon, refCounter);
- }
-
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Image.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Image.java
deleted file mode 100644
index a261c2f4b1..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Image.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.support.annotation.Keep;
-
-@Keep
-class Image {
- private final byte[] buffer;
- private final float pixelRatio;
- private final String name;
- private final int width;
- private final int height;
- private final boolean sdf;
-
- public Image(byte[] buffer, float pixelRatio, String name, int width, int height, boolean sdf) {
- this.buffer = buffer;
- this.pixelRatio = pixelRatio;
- this.name = name;
- this.width = width;
- this.height = height;
- this.sdf = sdf;
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/InfoWindowManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/InfoWindowManager.java
deleted file mode 100644
index 434244a7c1..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/InfoWindowManager.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.support.annotation.Nullable;
-import android.text.TextUtils;
-
-import com.mapbox.mapboxsdk.annotations.InfoWindow;
-import com.mapbox.mapboxsdk.annotations.Marker;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Responsible for managing InfoWindows shown on the Map.
- * <p>
- * Maintains a {@link List} of opened {@link InfoWindow} and tracks configurations as
- * allowConcurrentMultipleInfoWindows which allows to have multiple {@link InfoWindow} open at the
- * same time. Responsible for managing listeners as
- * {@link com.mapbox.mapboxsdk.maps.MapboxMap.OnInfoWindowClickListener} and
- * {@link com.mapbox.mapboxsdk.maps.MapboxMap.OnInfoWindowLongClickListener}.
- * </p>
- */
-class InfoWindowManager {
-
- private final List<InfoWindow> infoWindows = new ArrayList<>();
-
- @Nullable
- private MapboxMap.InfoWindowAdapter infoWindowAdapter;
- private boolean allowConcurrentMultipleInfoWindows;
-
- @Nullable
- private MapboxMap.OnInfoWindowClickListener onInfoWindowClickListener;
- @Nullable
- private MapboxMap.OnInfoWindowLongClickListener onInfoWindowLongClickListener;
- @Nullable
- private MapboxMap.OnInfoWindowCloseListener onInfoWindowCloseListener;
-
- void update() {
- if (!infoWindows.isEmpty()) {
- for (InfoWindow infoWindow : infoWindows) {
- infoWindow.update();
- }
- }
- }
-
- void setInfoWindowAdapter(@Nullable MapboxMap.InfoWindowAdapter infoWindowAdapter) {
- this.infoWindowAdapter = infoWindowAdapter;
- }
-
- @Nullable
- MapboxMap.InfoWindowAdapter getInfoWindowAdapter() {
- return infoWindowAdapter;
- }
-
- void setAllowConcurrentMultipleOpenInfoWindows(boolean allow) {
- allowConcurrentMultipleInfoWindows = allow;
- }
-
- boolean isAllowConcurrentMultipleOpenInfoWindows() {
- return allowConcurrentMultipleInfoWindows;
- }
-
- boolean isInfoWindowValidForMarker(@Nullable Marker marker) {
- return marker != null && (!TextUtils.isEmpty(marker.getTitle()) || !TextUtils.isEmpty(marker.getSnippet()));
- }
-
- void setOnInfoWindowClickListener(@Nullable MapboxMap.OnInfoWindowClickListener listener) {
- onInfoWindowClickListener = listener;
- }
-
- @Nullable
- MapboxMap.OnInfoWindowClickListener getOnInfoWindowClickListener() {
- return onInfoWindowClickListener;
- }
-
- void setOnInfoWindowLongClickListener(@Nullable MapboxMap.OnInfoWindowLongClickListener listener) {
- onInfoWindowLongClickListener = listener;
- }
-
- @Nullable
- MapboxMap.OnInfoWindowLongClickListener getOnInfoWindowLongClickListener() {
- return onInfoWindowLongClickListener;
- }
-
- void setOnInfoWindowCloseListener(@Nullable MapboxMap.OnInfoWindowCloseListener listener) {
- onInfoWindowCloseListener = listener;
- }
-
- @Nullable
- MapboxMap.OnInfoWindowCloseListener getOnInfoWindowCloseListener() {
- return onInfoWindowCloseListener;
- }
-
- public void add(InfoWindow infoWindow) {
- infoWindows.add(infoWindow);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapChangeReceiver.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapChangeReceiver.java
deleted file mode 100644
index 5932f6fbfe..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapChangeReceiver.java
+++ /dev/null
@@ -1,395 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import com.mapbox.mapboxsdk.log.Logger;
-
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-class MapChangeReceiver implements NativeMapView.StateCallback {
-
- private static final String TAG = "Mbgl-MapChangeReceiver";
-
- private final List<MapView.OnCameraWillChangeListener> onCameraWillChangeListenerList = new CopyOnWriteArrayList<>();
- private final List<MapView.OnCameraIsChangingListener> onCameraIsChangingListenerList = new CopyOnWriteArrayList<>();
- private final List<MapView.OnCameraDidChangeListener> onCameraDidChangeListenerList = new CopyOnWriteArrayList<>();
- private final List<MapView.OnWillStartLoadingMapListener> onWillStartLoadingMapListenerList
- = new CopyOnWriteArrayList<>();
- private final List<MapView.OnDidFinishLoadingMapListener> onDidFinishLoadingMapListenerList
- = new CopyOnWriteArrayList<>();
- private final List<MapView.OnDidFailLoadingMapListener> onDidFailLoadingMapListenerList
- = new CopyOnWriteArrayList<>();
- private final List<MapView.OnWillStartRenderingFrameListener> onWillStartRenderingFrameList
- = new CopyOnWriteArrayList<>();
- private final List<MapView.OnDidFinishRenderingFrameListener> onDidFinishRenderingFrameList
- = new CopyOnWriteArrayList<>();
- private final List<MapView.OnWillStartRenderingMapListener> onWillStartRenderingMapListenerList
- = new CopyOnWriteArrayList<>();
- private final List<MapView.OnDidFinishRenderingMapListener> onDidFinishRenderingMapListenerList
- = new CopyOnWriteArrayList<>();
- private final List<MapView.OnDidBecomeIdleListener> onDidBecomeIdleListenerList
- = new CopyOnWriteArrayList<>();
- private final List<MapView.OnDidFinishLoadingStyleListener> onDidFinishLoadingStyleListenerList
- = new CopyOnWriteArrayList<>();
- private final List<MapView.OnSourceChangedListener> onSourceChangedListenerList = new CopyOnWriteArrayList<>();
- private final List<MapView.OnStyleImageMissingListener> onStyleImageMissingListenerList
- = new CopyOnWriteArrayList<>();
- private final List<MapView.OnCanRemoveUnusedStyleImageListener> onCanRemoveUnusedStyleImageListenerList
- = new CopyOnWriteArrayList<>();
-
- @Override
- public void onCameraWillChange(boolean animated) {
- try {
- if (!onCameraWillChangeListenerList.isEmpty()) {
- for (MapView.OnCameraWillChangeListener onCameraWillChangeListener : onCameraWillChangeListenerList) {
- onCameraWillChangeListener.onCameraWillChange(animated);
- }
- }
- } catch (Throwable err) {
- Logger.e(TAG, "Exception in onCameraWillChange", err);
- throw err;
- }
- }
-
- @Override
- public void onCameraIsChanging() {
- try {
- if (!onCameraIsChangingListenerList.isEmpty()) {
- for (MapView.OnCameraIsChangingListener onCameraIsChangingListener : onCameraIsChangingListenerList) {
- onCameraIsChangingListener.onCameraIsChanging();
- }
- }
- } catch (Throwable err) {
- Logger.e(TAG, "Exception in onCameraIsChanging", err);
- throw err;
- }
- }
-
- @Override
- public void onCameraDidChange(boolean animated) {
- try {
- if (!onCameraDidChangeListenerList.isEmpty()) {
- for (MapView.OnCameraDidChangeListener onCameraDidChangeListener : onCameraDidChangeListenerList) {
- onCameraDidChangeListener.onCameraDidChange(animated);
- }
- }
- } catch (Throwable err) {
- Logger.e(TAG, "Exception in onCameraDidChange", err);
- throw err;
- }
- }
-
- @Override
- public void onWillStartLoadingMap() {
- try {
- if (!onWillStartLoadingMapListenerList.isEmpty()) {
- for (MapView.OnWillStartLoadingMapListener onWillStartLoadingMapListener : onWillStartLoadingMapListenerList) {
- onWillStartLoadingMapListener.onWillStartLoadingMap();
- }
- }
- } catch (Throwable err) {
- Logger.e(TAG, "Exception in onWillStartLoadingMap", err);
- throw err;
- }
- }
-
- @Override
- public void onDidFinishLoadingMap() {
- try {
- if (!onDidFinishLoadingMapListenerList.isEmpty()) {
- for (MapView.OnDidFinishLoadingMapListener onDidFinishLoadingMapListener : onDidFinishLoadingMapListenerList) {
- onDidFinishLoadingMapListener.onDidFinishLoadingMap();
- }
- }
- } catch (Throwable err) {
- Logger.e(TAG, "Exception in onDidFinishLoadingMap", err);
- throw err;
- }
- }
-
- @Override
- public void onDidFailLoadingMap(String error) {
- try {
- if (!onDidFailLoadingMapListenerList.isEmpty()) {
- for (MapView.OnDidFailLoadingMapListener onDidFailLoadingMapListener : onDidFailLoadingMapListenerList) {
- onDidFailLoadingMapListener.onDidFailLoadingMap(error);
- }
- }
- } catch (Throwable err) {
- Logger.e(TAG, "Exception in onDidFailLoadingMap", err);
- throw err;
- }
- }
-
- @Override
- public void onWillStartRenderingFrame() {
- try {
- if (!onWillStartRenderingFrameList.isEmpty()) {
- for (MapView.OnWillStartRenderingFrameListener listener : onWillStartRenderingFrameList) {
- listener.onWillStartRenderingFrame();
- }
- }
- } catch (Throwable err) {
- Logger.e(TAG, "Exception in onWillStartRenderingFrame", err);
- throw err;
- }
- }
-
- @Override
- public void onDidFinishRenderingFrame(boolean fully) {
- try {
- if (!onDidFinishRenderingFrameList.isEmpty()) {
- for (MapView.OnDidFinishRenderingFrameListener listener : onDidFinishRenderingFrameList) {
- listener.onDidFinishRenderingFrame(fully);
- }
- }
- } catch (Throwable err) {
- Logger.e(TAG, "Exception in onDidFinishRenderingFrame", err);
- throw err;
- }
- }
-
- @Override
- public void onWillStartRenderingMap() {
- try {
- if (!onWillStartRenderingMapListenerList.isEmpty()) {
- for (MapView.OnWillStartRenderingMapListener listener : onWillStartRenderingMapListenerList) {
- listener.onWillStartRenderingMap();
- }
- }
- } catch (Throwable err) {
- Logger.e(TAG, "Exception in onWillStartRenderingMap", err);
- throw err;
- }
- }
-
- @Override
- public void onDidFinishRenderingMap(boolean fully) {
- try {
- if (!onDidFinishRenderingMapListenerList.isEmpty()) {
- for (MapView.OnDidFinishRenderingMapListener listener : onDidFinishRenderingMapListenerList) {
- listener.onDidFinishRenderingMap(fully);
- }
- }
- } catch (Throwable err) {
- Logger.e(TAG, "Exception in onDidFinishRenderingMap", err);
- throw err;
- }
- }
-
- @Override
- public void onDidBecomeIdle() {
- try {
- if (!onDidBecomeIdleListenerList.isEmpty()) {
- for (MapView.OnDidBecomeIdleListener listener : onDidBecomeIdleListenerList) {
- listener.onDidBecomeIdle();
- }
- }
- } catch (Throwable err) {
- Logger.e(TAG, "Exception in onDidBecomeIdle", err);
- throw err;
- }
- }
-
- @Override
- public void onDidFinishLoadingStyle() {
- try {
- if (!onDidFinishLoadingStyleListenerList.isEmpty()) {
- for (MapView.OnDidFinishLoadingStyleListener listener : onDidFinishLoadingStyleListenerList) {
- listener.onDidFinishLoadingStyle();
- }
- }
- } catch (Throwable err) {
- Logger.e(TAG, "Exception in onDidFinishLoadingStyle", err);
- throw err;
- }
- }
-
- @Override
- public void onSourceChanged(String sourceId) {
- try {
- if (!onSourceChangedListenerList.isEmpty()) {
- for (MapView.OnSourceChangedListener onSourceChangedListener : onSourceChangedListenerList) {
- onSourceChangedListener.onSourceChangedListener(sourceId);
- }
- }
- } catch (Throwable err) {
- Logger.e(TAG, "Exception in onSourceChanged", err);
- throw err;
- }
- }
-
- @Override
- public void onStyleImageMissing(String imageId) {
- try {
- if (!onStyleImageMissingListenerList.isEmpty()) {
- for (MapView.OnStyleImageMissingListener listener : onStyleImageMissingListenerList) {
- listener.onStyleImageMissing(imageId);
- }
- }
- } catch (Throwable err) {
- Logger.e(TAG, "Exception in onStyleImageMissing", err);
- throw err;
- }
- }
-
- @Override
- public boolean onCanRemoveUnusedStyleImage(String imageId) {
- if (onCanRemoveUnusedStyleImageListenerList.isEmpty()) {
- return true;
- }
-
- try {
- if (!onCanRemoveUnusedStyleImageListenerList.isEmpty()) {
- boolean canRemove = true;
- for (MapView.OnCanRemoveUnusedStyleImageListener listener : onCanRemoveUnusedStyleImageListenerList) {
- canRemove &= listener.onCanRemoveUnusedStyleImage(imageId);
- }
-
- return canRemove;
- }
- } catch (Throwable err) {
- Logger.e(TAG, "Exception in onCanRemoveUnusedStyleImage", err);
- throw err;
- }
-
- return true;
- }
-
- void addOnCameraWillChangeListener(MapView.OnCameraWillChangeListener listener) {
- onCameraWillChangeListenerList.add(listener);
- }
-
- void removeOnCameraWillChangeListener(MapView.OnCameraWillChangeListener listener) {
- onCameraWillChangeListenerList.remove(listener);
- }
-
- void addOnCameraIsChangingListener(MapView.OnCameraIsChangingListener listener) {
- onCameraIsChangingListenerList.add(listener);
- }
-
- void removeOnCameraIsChangingListener(MapView.OnCameraIsChangingListener listener) {
- onCameraIsChangingListenerList.remove(listener);
- }
-
- void addOnCameraDidChangeListener(MapView.OnCameraDidChangeListener listener) {
- onCameraDidChangeListenerList.add(listener);
- }
-
- void removeOnCameraDidChangeListener(MapView.OnCameraDidChangeListener listener) {
- onCameraDidChangeListenerList.remove(listener);
- }
-
- void addOnWillStartLoadingMapListener(MapView.OnWillStartLoadingMapListener listener) {
- onWillStartLoadingMapListenerList.add(listener);
- }
-
- void removeOnWillStartLoadingMapListener(MapView.OnWillStartLoadingMapListener listener) {
- onWillStartLoadingMapListenerList.remove(listener);
- }
-
- void addOnDidFinishLoadingMapListener(MapView.OnDidFinishLoadingMapListener listener) {
- onDidFinishLoadingMapListenerList.add(listener);
- }
-
- void removeOnDidFinishLoadingMapListener(MapView.OnDidFinishLoadingMapListener listener) {
- onDidFinishLoadingMapListenerList.remove(listener);
- }
-
- void addOnDidFailLoadingMapListener(MapView.OnDidFailLoadingMapListener listener) {
- onDidFailLoadingMapListenerList.add(listener);
- }
-
- void removeOnDidFailLoadingMapListener(MapView.OnDidFailLoadingMapListener listener) {
- onDidFailLoadingMapListenerList.remove(listener);
- }
-
- void addOnWillStartRenderingFrameListener(MapView.OnWillStartRenderingFrameListener listener) {
- onWillStartRenderingFrameList.add(listener);
- }
-
- void removeOnWillStartRenderingFrameListener(MapView.OnWillStartRenderingFrameListener listener) {
- onWillStartRenderingFrameList.remove(listener);
- }
-
- void addOnDidFinishRenderingFrameListener(MapView.OnDidFinishRenderingFrameListener listener) {
- onDidFinishRenderingFrameList.add(listener);
- }
-
- void removeOnDidFinishRenderingFrameListener(MapView.OnDidFinishRenderingFrameListener listener) {
- onDidFinishRenderingFrameList.remove(listener);
- }
-
- void addOnWillStartRenderingMapListener(MapView.OnWillStartRenderingMapListener listener) {
- onWillStartRenderingMapListenerList.add(listener);
- }
-
- void removeOnWillStartRenderingMapListener(MapView.OnWillStartRenderingMapListener listener) {
- onWillStartRenderingMapListenerList.remove(listener);
- }
-
- void addOnDidFinishRenderingMapListener(MapView.OnDidFinishRenderingMapListener listener) {
- onDidFinishRenderingMapListenerList.add(listener);
- }
-
- void removeOnDidFinishRenderingMapListener(MapView.OnDidFinishRenderingMapListener listener) {
- onDidFinishRenderingMapListenerList.remove(listener);
- }
-
- void addOnDidBecomeIdleListener(MapView.OnDidBecomeIdleListener listener) {
- onDidBecomeIdleListenerList.add(listener);
- }
-
- void removeOnDidBecomeIdleListener(MapView.OnDidBecomeIdleListener listener) {
- onDidBecomeIdleListenerList.remove(listener);
- }
-
- void addOnDidFinishLoadingStyleListener(MapView.OnDidFinishLoadingStyleListener listener) {
- onDidFinishLoadingStyleListenerList.add(listener);
- }
-
- void removeOnDidFinishLoadingStyleListener(MapView.OnDidFinishLoadingStyleListener listener) {
- onDidFinishLoadingStyleListenerList.remove(listener);
- }
-
- void addOnSourceChangedListener(MapView.OnSourceChangedListener listener) {
- onSourceChangedListenerList.add(listener);
- }
-
- void removeOnSourceChangedListener(MapView.OnSourceChangedListener listener) {
- onSourceChangedListenerList.remove(listener);
- }
-
- void addOnStyleImageMissingListener(MapView.OnStyleImageMissingListener listener) {
- onStyleImageMissingListenerList.add(listener);
- }
-
- void removeOnStyleImageMissingListener(MapView.OnStyleImageMissingListener listener) {
- onStyleImageMissingListenerList.remove(listener);
- }
-
- void addOnCanRemoveUnusedStyleImageListener(MapView.OnCanRemoveUnusedStyleImageListener listener) {
- onCanRemoveUnusedStyleImageListenerList.add(listener);
- }
-
- void removeOnCanRemoveUnusedStyleImageListener(MapView.OnCanRemoveUnusedStyleImageListener listener) {
- onCanRemoveUnusedStyleImageListenerList.remove(listener);
- }
-
- void clear() {
- onCameraWillChangeListenerList.clear();
- onCameraIsChangingListenerList.clear();
- onCameraDidChangeListenerList.clear();
- onWillStartLoadingMapListenerList.clear();
- onDidFinishLoadingMapListenerList.clear();
- onDidFailLoadingMapListenerList.clear();
- onWillStartRenderingFrameList.clear();
- onDidFinishRenderingFrameList.clear();
- onWillStartRenderingMapListenerList.clear();
- onDidFinishRenderingMapListenerList.clear();
- onDidBecomeIdleListenerList.clear();
- onDidFinishLoadingStyleListenerList.clear();
- onSourceChangedListenerList.clear();
- onStyleImageMissingListenerList.clear();
- onCanRemoveUnusedStyleImageListenerList.clear();
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java
deleted file mode 100644
index 8af9f2c6a8..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapFragment.java
+++ /dev/null
@@ -1,241 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.app.Fragment;
-import android.content.Context;
-import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.util.AttributeSet;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import com.mapbox.mapboxsdk.utils.MapFragmentUtils;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Fragment wrapper around a map view.
- * <p>
- * A Map component in an app. This fragment is the simplest way to place a map in an application.
- * It's a wrapper around a view of a map to automatically handle the necessary life cycle needs.
- * Being a fragment, this component can be added to an activity's layout or can dynamically be added
- * using a FragmentManager.
- * </p>
- * <p>
- * To get a reference to the MapView, use {@link #getMapAsync(OnMapReadyCallback)}}
- * </p>
- *
- * @see #getMapAsync(OnMapReadyCallback)
- */
-public final class MapFragment extends Fragment implements OnMapReadyCallback {
-
- private final List<OnMapReadyCallback> mapReadyCallbackList = new ArrayList<>();
- private OnMapViewReadyCallback mapViewReadyCallback;
- private MapboxMap mapboxMap;
- private MapView map;
-
- /**
- * Creates a default MapFragment instance
- *
- * @return MapFragment instantiated
- */
- public static MapFragment newInstance() {
- return new MapFragment();
- }
-
- /**
- * Creates a MapFragment instance
- *
- * @param mapboxMapOptions The configuration options to be used.
- * @return MapFragment instantiated.
- */
- @NonNull
- public static MapFragment newInstance(@Nullable MapboxMapOptions mapboxMapOptions) {
- MapFragment mapFragment = new MapFragment();
- mapFragment.setArguments(MapFragmentUtils.createFragmentArgs(mapboxMapOptions));
- return mapFragment;
- }
-
- /**
- * Called when this fragment is inflated, parses XML tag attributes.
- *
- * @param context The context inflating this fragment.
- * @param attrs The XML tag attributes.
- * @param savedInstanceState The saved instance state for the map fragment.
- */
- @Override
- public void onInflate(@NonNull Context context, AttributeSet attrs, Bundle savedInstanceState) {
- super.onInflate(context, attrs, savedInstanceState);
- setArguments(MapFragmentUtils.createFragmentArgs(MapboxMapOptions.createFromAttributes(context, attrs)));
- }
-
- /**
- * Called when the context attaches to this fragment.
- *
- * @param context the context attaching
- */
- @Override
- public void onAttach(Context context) {
- super.onAttach(context);
- if (context instanceof OnMapViewReadyCallback) {
- mapViewReadyCallback = (OnMapViewReadyCallback) context;
- }
- }
-
- /**
- * Creates the fragment view hierarchy.
- *
- * @param inflater Inflater used to inflate content.
- * @param container The parent layout for the map fragment.
- * @param savedInstanceState The saved instance state for the map fragment.
- * @return The view created
- */
- @Override
- public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- super.onCreateView(inflater, container, savedInstanceState);
- Context context = inflater.getContext();
- map = new MapView(context, MapFragmentUtils.resolveArgs(context, getArguments()));
- return map;
- }
-
- /**
- * Called when the fragment view hierarchy is created.
- *
- * @param view The content view of the fragment
- * @param savedInstanceState The saved instance state of the fragment
- */
- @Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
- map.onCreate(savedInstanceState);
- map.getMapAsync(this);
-
- // notify listeners about mapview creation
- if (mapViewReadyCallback != null) {
- mapViewReadyCallback.onMapViewReady(map);
- }
- }
-
- /**
- * Called when the style of the map has successfully loaded.
- *
- * @param mapboxMap The public api controller of the map
- */
- @Override
- public void onMapReady(@NonNull MapboxMap mapboxMap) {
- this.mapboxMap = mapboxMap;
- for (OnMapReadyCallback onMapReadyCallback : mapReadyCallbackList) {
- onMapReadyCallback.onMapReady(mapboxMap);
- }
- }
-
- /**
- * Called when the fragment is visible for the users.
- */
- @Override
- public void onStart() {
- super.onStart();
- map.onStart();
- }
-
- /**
- * Called when the fragment is ready to be interacted with.
- */
- @Override
- public void onResume() {
- super.onResume();
- map.onResume();
- }
-
- /**
- * Called when the fragment is pausing.
- */
- @Override
- public void onPause() {
- super.onPause();
- map.onPause();
- }
-
- /**
- * Called when the fragment state needs to be saved.
- *
- * @param outState The saved state
- */
- @Override
- public void onSaveInstanceState(@NonNull Bundle outState) {
- super.onSaveInstanceState(outState);
- if (map != null && !map.isDestroyed()) {
- map.onSaveInstanceState(outState);
- }
- }
-
- /**
- * Called when the fragment is no longer visible for the user.
- */
- @Override
- public void onStop() {
- super.onStop();
- map.onStop();
- }
-
- /**
- * Called when the fragment receives onLowMemory call from the hosting Activity.
- */
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- if (map != null && !map.isDestroyed()) {
- map.onLowMemory();
- }
- }
-
- /**
- * Called when the fragment is view hiearchy is being destroyed.
- */
- @Override
- public void onDestroyView() {
- super.onDestroyView();
- map.onDestroy();
- }
-
- /**
- * Called when the fragment is destroyed.
- */
- @Override
- public void onDestroy() {
- super.onDestroy();
- mapReadyCallbackList.clear();
- }
-
- /**
- * Sets a callback object which will be triggered when the MapboxMap instance is ready to be used.
- *
- * @param onMapReadyCallback The callback to be invoked.
- */
- public void getMapAsync(@NonNull final OnMapReadyCallback onMapReadyCallback) {
- if (mapboxMap == null) {
- mapReadyCallbackList.add(onMapReadyCallback);
- } else {
- onMapReadyCallback.onMapReady(mapboxMap);
- }
- }
-
- /**
- * Callback to be invoked when the map fragment has inflated its MapView.
- * <p>
- * To use this interface the context hosting the fragment must implement this interface.
- * That instance will be set as part of Fragment#onAttach(Context context).
- * </p>
- */
- public interface OnMapViewReadyCallback {
-
- /**
- * Called when the map has been created.
- *
- * @param mapView The created mapview
- */
- void onMapViewReady(MapView mapView);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java
deleted file mode 100644
index 90e3934f7c..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java
+++ /dev/null
@@ -1,1140 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
-import android.animation.ValueAnimator;
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.PointF;
-import android.os.Handler;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.view.InputDevice;
-import android.view.MotionEvent;
-import android.view.animation.DecelerateInterpolator;
-
-import com.mapbox.android.gestures.AndroidGesturesManager;
-import com.mapbox.android.gestures.MoveGestureDetector;
-import com.mapbox.android.gestures.MultiFingerTapGestureDetector;
-import com.mapbox.android.gestures.RotateGestureDetector;
-import com.mapbox.android.gestures.ShoveGestureDetector;
-import com.mapbox.android.gestures.StandardGestureDetector;
-import com.mapbox.android.gestures.StandardScaleGestureDetector;
-import com.mapbox.mapboxsdk.R;
-import com.mapbox.mapboxsdk.constants.MapboxConstants;
-import com.mapbox.mapboxsdk.utils.MathUtils;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import static com.mapbox.mapboxsdk.constants.MapboxConstants.MAXIMUM_ANGULAR_VELOCITY;
-import static com.mapbox.mapboxsdk.constants.MapboxConstants.MAX_ABSOLUTE_SCALE_VELOCITY_CHANGE;
-import static com.mapbox.mapboxsdk.constants.MapboxConstants.QUICK_ZOOM_MAX_ZOOM_CHANGE;
-import static com.mapbox.mapboxsdk.constants.MapboxConstants.ROTATE_VELOCITY_RATIO_THRESHOLD;
-import static com.mapbox.mapboxsdk.constants.MapboxConstants.SCALE_VELOCITY_ANIMATION_DURATION_MULTIPLIER;
-import static com.mapbox.mapboxsdk.constants.MapboxConstants.SCALE_VELOCITY_RATIO_THRESHOLD;
-import static com.mapbox.mapboxsdk.constants.MapboxConstants.ZOOM_RATE;
-import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener.REASON_API_GESTURE;
-import static com.mapbox.mapboxsdk.utils.MathUtils.normalize;
-
-/**
- * Manages gestures events on a MapView.
- */
-final class MapGestureDetector {
-
- private final Transform transform;
- private final Projection projection;
- private final UiSettings uiSettings;
- private final AnnotationManager annotationManager;
- private final CameraChangeDispatcher cameraChangeDispatcher;
-
- // new map touch API
- private final CopyOnWriteArrayList<MapboxMap.OnMapClickListener> onMapClickListenerList
- = new CopyOnWriteArrayList<>();
-
- private final CopyOnWriteArrayList<MapboxMap.OnMapLongClickListener> onMapLongClickListenerList
- = new CopyOnWriteArrayList<>();
-
- private final CopyOnWriteArrayList<MapboxMap.OnFlingListener> onFlingListenerList
- = new CopyOnWriteArrayList<>();
-
- private final CopyOnWriteArrayList<MapboxMap.OnMoveListener> onMoveListenerList
- = new CopyOnWriteArrayList<>();
-
- private final CopyOnWriteArrayList<MapboxMap.OnRotateListener> onRotateListenerList
- = new CopyOnWriteArrayList<>();
-
- private final CopyOnWriteArrayList<MapboxMap.OnScaleListener> onScaleListenerList
- = new CopyOnWriteArrayList<>();
-
- private final CopyOnWriteArrayList<MapboxMap.OnShoveListener> onShoveListenerList
- = new CopyOnWriteArrayList<>();
-
- /**
- * User-set focal point.
- */
- @Nullable
- private PointF constantFocalPoint;
-
- @NonNull
- private PointF doubleTapFocalPoint = new PointF();
-
- private AndroidGesturesManager gesturesManager;
-
- private Animator scaleAnimator;
- private Animator rotateAnimator;
- private final List<Animator> scheduledAnimators = new ArrayList<>();
-
- /**
- * Cancels scheduled velocity animations if user doesn't lift fingers within
- * {@link MapboxConstants#SCHEDULED_ANIMATION_TIMEOUT}
- */
- @NonNull
- private Handler animationsTimeoutHandler = new Handler();
-
- private boolean doubleTapRegistered;
-
- MapGestureDetector(@Nullable Context context, Transform transform, Projection projection, UiSettings uiSettings,
- AnnotationManager annotationManager, CameraChangeDispatcher cameraChangeDispatcher) {
- this.annotationManager = annotationManager;
- this.transform = transform;
- this.projection = projection;
- this.uiSettings = uiSettings;
- this.cameraChangeDispatcher = cameraChangeDispatcher;
-
- // Checking for context != null for testing purposes
- if (context != null) {
- // Initialize gestures manager
- AndroidGesturesManager androidGesturesManager = new AndroidGesturesManager(context);
- initializeGesturesManager(androidGesturesManager, true);
-
- // Initialize gesture listeners
- initializeGestureListeners(context, true);
- }
- }
-
- private void initializeGestureListeners(@NonNull Context context, boolean attachDefaultListeners) {
- if (attachDefaultListeners) {
- StandardGestureListener standardGestureListener = new StandardGestureListener(
- context.getResources().getDimension(
- com.mapbox.android.gestures.R.dimen.mapbox_defaultScaleSpanSinceStartThreshold));
- MoveGestureListener moveGestureListener = new MoveGestureListener();
- ScaleGestureListener scaleGestureListener = new ScaleGestureListener(
- context.getResources().getDimension(R.dimen.mapbox_density_constant),
- context.getResources().getDimension(R.dimen.mapbox_minimum_scale_speed),
- context.getResources().getDimension(R.dimen.mapbox_minimum_angled_scale_speed),
- context.getResources().getDimension(R.dimen.mapbox_minimum_scale_velocity)
- );
- RotateGestureListener rotateGestureListener = new RotateGestureListener(
- context.getResources().getDimension(R.dimen.mapbox_minimum_scale_span_when_rotating),
- context.getResources().getDimension(R.dimen.mapbox_density_constant),
- context.getResources().getDimension(R.dimen.mapbox_angular_velocity_multiplier),
- context.getResources().getDimension(R.dimen.mapbox_minimum_angular_velocity),
- context.getResources().getDimension(
- com.mapbox.android.gestures.R.dimen.mapbox_defaultScaleSpanSinceStartThreshold));
- ShoveGestureListener shoveGestureListener = new ShoveGestureListener();
- TapGestureListener tapGestureListener = new TapGestureListener();
-
- gesturesManager.setStandardGestureListener(standardGestureListener);
- gesturesManager.setMoveGestureListener(moveGestureListener);
- gesturesManager.setStandardScaleGestureListener(scaleGestureListener);
- gesturesManager.setRotateGestureListener(rotateGestureListener);
- gesturesManager.setShoveGestureListener(shoveGestureListener);
- gesturesManager.setMultiFingerTapGestureListener(tapGestureListener);
- }
- }
-
- private void initializeGesturesManager(@NonNull AndroidGesturesManager androidGesturesManager,
- boolean setDefaultMutuallyExclusives) {
- if (setDefaultMutuallyExclusives) {
- Set<Integer> shoveScaleSet = new HashSet<>();
- shoveScaleSet.add(AndroidGesturesManager.GESTURE_TYPE_SHOVE);
- shoveScaleSet.add(AndroidGesturesManager.GESTURE_TYPE_SCALE);
-
- Set<Integer> shoveRotateSet = new HashSet<>();
- shoveRotateSet.add(AndroidGesturesManager.GESTURE_TYPE_SHOVE);
- shoveRotateSet.add(AndroidGesturesManager.GESTURE_TYPE_ROTATE);
-
- Set<Integer> ScaleLongPressSet = new HashSet<>();
- ScaleLongPressSet.add(AndroidGesturesManager.GESTURE_TYPE_SCALE);
- ScaleLongPressSet.add(AndroidGesturesManager.GESTURE_TYPE_LONG_PRESS);
-
- androidGesturesManager.setMutuallyExclusiveGestures(shoveScaleSet, shoveRotateSet, ScaleLongPressSet);
- }
-
- gesturesManager = androidGesturesManager;
- gesturesManager.getRotateGestureDetector().setAngleThreshold(3f);
- }
-
- /**
- * Set the gesture focal point.
- * <p>
- * This is the center point used for calculate transformations from gestures, value is
- * overridden if end user provides his own through {@link UiSettings#setFocalPoint(PointF)}.
- * </p>
- *
- * @param focalPoint the center point for gestures
- */
- void setFocalPoint(@Nullable PointF focalPoint) {
- if (focalPoint == null) {
- // resetting focal point,
- if (uiSettings.getFocalPoint() != null) {
- // using user provided one to reset
- focalPoint = uiSettings.getFocalPoint();
- }
- }
- this.constantFocalPoint = focalPoint;
- }
-
- /**
- * Called when user touches the screen, all positions are absolute.
- * <p>
- * Forwards event to the related gesture detectors.
- * </p>
- *
- * @param motionEvent the MotionEvent
- * @return True if touch event is handled
- */
- boolean onTouchEvent(@Nullable MotionEvent motionEvent) {
- // Framework can return null motion events in edge cases #9432
- if (motionEvent == null) {
- return false;
- }
-
- // Check and ignore non touch or left clicks
- if ((motionEvent.getButtonState() != 0) && (motionEvent.getButtonState() != MotionEvent.BUTTON_PRIMARY)) {
- return false;
- }
-
- if (motionEvent.getActionMasked() == MotionEvent.ACTION_DOWN) {
- cancelAnimators();
- transform.setGestureInProgress(true);
- }
-
- boolean result = gesturesManager.onTouchEvent(motionEvent);
-
- switch (motionEvent.getActionMasked()) {
- case MotionEvent.ACTION_POINTER_DOWN:
- doubleTapFinished();
- break;
-
- case MotionEvent.ACTION_UP:
- doubleTapFinished();
- transform.setGestureInProgress(false);
-
- if (!scheduledAnimators.isEmpty()) {
- // Start all awaiting velocity animations
- animationsTimeoutHandler.removeCallbacksAndMessages(null);
- for (Animator animator : scheduledAnimators) {
- animator.start();
- }
- scheduledAnimators.clear();
- }
- break;
-
- case MotionEvent.ACTION_CANCEL:
- scheduledAnimators.clear();
- transform.setGestureInProgress(false);
- doubleTapFinished();
- break;
- }
-
- return result;
- }
-
- void cancelAnimators() {
- animationsTimeoutHandler.removeCallbacksAndMessages(null);
- scheduledAnimators.clear();
-
- cancelAnimator(scaleAnimator);
- cancelAnimator(rotateAnimator);
-
- dispatchCameraIdle();
- }
-
- private void cancelAnimator(@Nullable Animator animator) {
- if (animator != null && animator.isStarted()) {
- animator.cancel();
- }
- }
-
- /**
- * Posted on main thread with {@link #animationsTimeoutHandler}. Cancels all scheduled animators if needed.
- */
- @NonNull
- private final Runnable cancelAnimatorsRunnable = new Runnable() {
- @Override
- public void run() {
- cancelAnimators();
- }
- };
-
- /**
- * Schedules a velocity animator to be executed when user lifts fingers,
- * unless canceled by the {@link #cancelAnimatorsRunnable}.
- *
- * @param animator animator ot be scheduled
- */
- private void scheduleAnimator(Animator animator) {
- scheduledAnimators.add(animator);
- animationsTimeoutHandler.removeCallbacksAndMessages(null);
- animationsTimeoutHandler.postDelayed(cancelAnimatorsRunnable, MapboxConstants.SCHEDULED_ANIMATION_TIMEOUT);
- }
-
- /**
- * Called for events that don't fit the other handlers.
- * <p>
- * Examples of such events are mouse scroll events, mouse moves, joystick & trackpad.
- * </p>
- *
- * @param event The MotionEvent occurred
- * @return True is the event is handled
- */
- boolean onGenericMotionEvent(MotionEvent event) {
- // Mouse events
- // if (event.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) { // this is not available before API 18
- if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) == InputDevice.SOURCE_CLASS_POINTER) {
- // Choose the action
- switch (event.getActionMasked()) {
- // Mouse scrolls
- case MotionEvent.ACTION_SCROLL:
- if (!uiSettings.isZoomGesturesEnabled()) {
- return false;
- }
-
- // Cancel any animation
- transform.cancelTransitions();
-
- // Get the vertical scroll amount, one click = 1
- float scrollDist = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
-
- // Scale the map by the appropriate power of two factor
- transform.zoomBy(scrollDist, new PointF(event.getX(), event.getY()));
-
- return true;
-
- default:
- // We are not interested in this event
- return false;
- }
- }
-
- // We are not interested in this event
- return false;
- }
-
- private final class StandardGestureListener extends StandardGestureDetector.SimpleStandardOnGestureListener {
- private final float doubleTapMovementThreshold;
-
- StandardGestureListener(float doubleTapMovementThreshold) {
- this.doubleTapMovementThreshold = doubleTapMovementThreshold;
- }
-
- @Override
- public boolean onDown(MotionEvent motionEvent) {
- return true;
- }
-
- @Override
- public boolean onSingleTapUp(MotionEvent motionEvent) {
- transform.cancelTransitions();
- return true;
- }
-
- @Override
- public boolean onSingleTapConfirmed(MotionEvent motionEvent) {
- PointF tapPoint = new PointF(motionEvent.getX(), motionEvent.getY());
- boolean tapHandled = annotationManager.onTap(tapPoint);
-
- if (!tapHandled) {
- if (uiSettings.isDeselectMarkersOnTap()) {
- // deselect any selected marker
- annotationManager.deselectMarkers();
- }
-
- notifyOnMapClickListeners(tapPoint);
- }
-
- return true;
- }
-
- @Override
- public boolean onDoubleTapEvent(MotionEvent motionEvent) {
- int action = motionEvent.getActionMasked();
- if (action == MotionEvent.ACTION_DOWN) {
- doubleTapFocalPoint = new PointF(motionEvent.getX(), motionEvent.getY());
- doubleTapStarted();
- }
-
- if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP) {
- float diffX = Math.abs(motionEvent.getX() - doubleTapFocalPoint.x);
- float diffY = Math.abs(motionEvent.getY() - doubleTapFocalPoint.y);
- if (diffX > doubleTapMovementThreshold || diffY > doubleTapMovementThreshold) {
- // Ignore double-tap event because we've started the quick-zoom. See #14013.
- return false;
- }
-
- if (!uiSettings.isZoomGesturesEnabled() || !uiSettings.isDoubleTapGesturesEnabled()) {
- return false;
- }
-
- // Single finger double tap
- if (constantFocalPoint != null) {
- // User provided focal point
- doubleTapFocalPoint = constantFocalPoint;
- }
-
- zoomInAnimated(doubleTapFocalPoint, false);
-
- return true;
- }
-
- return super.onDoubleTapEvent(motionEvent);
- }
-
- @Override
- public void onLongPress(MotionEvent motionEvent) {
- PointF longClickPoint = new PointF(motionEvent.getX(), motionEvent.getY());
- notifyOnMapLongClickListeners(longClickPoint);
- }
-
- @Override
- public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
- if (!uiSettings.isScrollGesturesEnabled()) {
- // don't allow a fling if scroll is disabled
- return false;
- }
-
- notifyOnFlingListeners();
-
- if (!uiSettings.isFlingVelocityAnimationEnabled()) {
- return false;
- }
-
- float screenDensity = uiSettings.getPixelRatio();
-
- // calculate velocity vector for xy dimensions, independent from screen size
- double velocityXY = Math.hypot(velocityX / screenDensity, velocityY / screenDensity);
- if (velocityXY < MapboxConstants.VELOCITY_THRESHOLD_IGNORE_FLING) {
- // ignore short flings, these can occur when other gestures just have finished executing
- return false;
- }
-
- transform.cancelTransitions();
- cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
-
- // tilt results in a bigger translation, limiting input for #5281
- double tilt = transform.getTilt();
- double tiltFactor = 1.5 + ((tilt != 0) ? (tilt / 10) : 0);
- double offsetX = velocityX / tiltFactor / screenDensity;
- double offsetY = velocityY / tiltFactor / screenDensity;
-
- // calculate animation time based on displacement
- long animationTime = (long) (velocityXY / 7 / tiltFactor + MapboxConstants.ANIMATION_DURATION_FLING_BASE);
-
- // update transformation
- transform.moveBy(offsetX, offsetY, animationTime);
-
- return true;
- }
- }
-
- private void doubleTapStarted() {
- // disable the move detector in preparation for the quickzoom,
- // so that we don't move the map's center slightly before the quickzoom is started (see #14227)
- gesturesManager.getMoveGestureDetector().setEnabled(false);
- doubleTapRegistered = true;
- }
-
- private void doubleTapFinished() {
- if (doubleTapRegistered) {
- // re-enable the move detector in case of double tap
- gesturesManager.getMoveGestureDetector().setEnabled(true);
- doubleTapRegistered = false;
- }
- }
-
- private final class MoveGestureListener extends MoveGestureDetector.SimpleOnMoveGestureListener {
- @Override
- public boolean onMoveBegin(@NonNull MoveGestureDetector detector) {
- if (!uiSettings.isScrollGesturesEnabled()) {
- return false;
- }
-
- cancelTransitionsIfRequired();
- notifyOnMoveBeginListeners(detector);
- return true;
- }
-
- @Override
- public boolean onMove(@NonNull MoveGestureDetector detector, float distanceX, float distanceY) {
- // first move event is often delivered with no displacement
- if (distanceX != 0 || distanceY != 0) {
- // dispatching camera start event only when the movement actually occurred
- cameraChangeDispatcher.onCameraMoveStarted(CameraChangeDispatcher.REASON_API_GESTURE);
-
- // Scroll the map
- transform.moveBy(-distanceX, -distanceY, 0 /*no duration*/);
-
- notifyOnMoveListeners(detector);
- }
- return true;
- }
-
- @Override
- public void onMoveEnd(@NonNull MoveGestureDetector detector, float velocityX, float velocityY) {
- dispatchCameraIdle();
- notifyOnMoveEndListeners(detector);
- }
- }
-
- private final class ScaleGestureListener extends StandardScaleGestureDetector.SimpleStandardOnScaleGestureListener {
-
- private final float minimumGestureSpeed;
- private final float minimumAngledGestureSpeed;
- private final float minimumVelocity;
- private final double scaleVelocityRatioThreshold;
- private boolean quickZoom;
- private float spanSinceLast;
- private double screenHeight;
- private double startZoom;
-
- ScaleGestureListener(double densityMultiplier, float minimumGestureSpeed, float minimumAngledGestureSpeed,
- float minimumVelocity) {
- this.minimumGestureSpeed = minimumGestureSpeed;
- this.minimumAngledGestureSpeed = minimumAngledGestureSpeed;
- this.minimumVelocity = minimumVelocity;
- this.scaleVelocityRatioThreshold = SCALE_VELOCITY_RATIO_THRESHOLD * densityMultiplier;
- }
-
- @Override
- public boolean onScaleBegin(@NonNull StandardScaleGestureDetector detector) {
- quickZoom = detector.getPointersCount() == 1;
-
- if (!uiSettings.isZoomGesturesEnabled()) {
- return false;
- }
-
- if (quickZoom) {
- if (!uiSettings.isQuickZoomGesturesEnabled()) {
- return false;
- }
- // re-try disabling the move detector in case double tap has been interrupted before quickzoom started
- gesturesManager.getMoveGestureDetector().setEnabled(false);
- } else {
- if (detector.getPreviousSpan() > 0) {
- float currSpan = detector.getCurrentSpan();
- float prevSpan = detector.getPreviousSpan();
- double currTime = detector.getCurrentEvent().getEventTime();
- double prevTime = detector.getPreviousEvent().getEventTime();
- if (currTime == prevTime) {
- return false;
- }
- double speed = Math.abs(currSpan - prevSpan) / (currTime - prevTime);
- if (speed < minimumGestureSpeed) {
- // do not scale if the minimal gesture speed is not met
- return false;
- } else if (!gesturesManager.getRotateGestureDetector().isInProgress()) {
- float rotationDeltaSinceLast = gesturesManager.getRotateGestureDetector().getDeltaSinceLast();
- if (Math.abs(rotationDeltaSinceLast) > 0.4 && speed < minimumAngledGestureSpeed) {
- // do not scale in case we're preferring to start rotation
- return false;
- }
-
- if (uiSettings.isDisableRotateWhenScaling()) {
- // disable rotate gesture when scale is detected first
- gesturesManager.getRotateGestureDetector().setEnabled(false);
- }
- }
- } else {
- return false;
- }
- }
-
- screenHeight = Resources.getSystem().getDisplayMetrics().heightPixels;
- startZoom = transform.getRawZoom();
-
- cancelTransitionsIfRequired();
-
- notifyOnScaleBeginListeners(detector);
-
- spanSinceLast = Math.abs(detector.getCurrentSpan() - detector.getPreviousSpan());
-
- return true;
- }
-
- @Override
- public boolean onScale(@NonNull StandardScaleGestureDetector detector) {
- // dispatching camera start event only when the movement actually occurred
- cameraChangeDispatcher.onCameraMoveStarted(CameraChangeDispatcher.REASON_API_GESTURE);
-
- PointF focalPoint = getScaleFocalPoint(detector);
- if (quickZoom) {
- double pixelDeltaChange = Math.abs(detector.getCurrentEvent().getY() - doubleTapFocalPoint.y);
- boolean zoomedOut = detector.getCurrentEvent().getY() < doubleTapFocalPoint.y;
-
- // normalize the pixel delta change, ranging from 0 to screen height, to a constant zoom change range
- double normalizedDeltaChange = normalize(pixelDeltaChange, 0, screenHeight, 0, QUICK_ZOOM_MAX_ZOOM_CHANGE);
-
- // calculate target zoom and adjust for a multiplier
- double targetZoom = (zoomedOut ? startZoom - normalizedDeltaChange : startZoom + normalizedDeltaChange);
- targetZoom *= uiSettings.getZoomRate();
-
- transform.setZoom(targetZoom, focalPoint);
- } else {
- double zoomBy =
- (Math.log(detector.getScaleFactor()) / Math.log(Math.PI / 2)) * ZOOM_RATE * uiSettings.getZoomRate();
- transform.zoomBy(zoomBy, focalPoint);
- }
-
- notifyOnScaleListeners(detector);
-
- spanSinceLast = Math.abs(detector.getCurrentSpan() - detector.getPreviousSpan());
-
- return true;
- }
-
- @Override
- public void onScaleEnd(@NonNull StandardScaleGestureDetector detector, float velocityX, float velocityY) {
- if (quickZoom) {
- // re-enabled the move detector if the quickzoom happened
- gesturesManager.getMoveGestureDetector().setEnabled(true);
- } else {
- // re-enable rotation in case it's been disabled
- gesturesManager.getRotateGestureDetector().setEnabled(true);
- }
-
- notifyOnScaleEndListeners(detector);
-
- float velocityXY = Math.abs(velocityX) + Math.abs(velocityY);
-
- if (!uiSettings.isScaleVelocityAnimationEnabled()
- || velocityXY < minimumVelocity
- || spanSinceLast / velocityXY < scaleVelocityRatioThreshold) {
- // notifying listeners that camera is idle only if there is no follow-up animation
- dispatchCameraIdle();
- return;
- }
-
- double zoomAddition = calculateScale(velocityXY, detector.isScalingOut());
- double currentZoom = transform.getRawZoom();
- PointF focalPoint = getScaleFocalPoint(detector);
- // (log(x + 1 / e^2) + 2) * 150, x=0 to 2.5 (MapboxConstants#MAX_ABSOLUTE_SCALE_VELOCITY_CHANGE)
- long animationTime = (long) ((Math.log((Math.abs(zoomAddition)) + 1 / Math.pow(Math.E, 2)) + 2)
- * SCALE_VELOCITY_ANIMATION_DURATION_MULTIPLIER);
- scaleAnimator = createScaleAnimator(currentZoom, zoomAddition, focalPoint, animationTime);
- scheduleAnimator(scaleAnimator);
- }
-
- @NonNull
- private PointF getScaleFocalPoint(@NonNull StandardScaleGestureDetector detector) {
- if (constantFocalPoint != null) {
- // around user provided focal point
- return constantFocalPoint;
- } else if (quickZoom) {
- // around center
- return new PointF(uiSettings.getWidth() / 2, uiSettings.getHeight() / 2);
- } else {
- // around gesture
- return detector.getFocalPoint();
- }
- }
-
- private double calculateScale(double velocityXY, boolean isScalingOut) {
- double zoomAddition = velocityXY * MAX_ABSOLUTE_SCALE_VELOCITY_CHANGE * 1e-4;
- zoomAddition = MathUtils.clamp(zoomAddition, 0, MAX_ABSOLUTE_SCALE_VELOCITY_CHANGE);
- if (isScalingOut) {
- zoomAddition = -zoomAddition;
- }
- return zoomAddition;
- }
- }
-
- private final class RotateGestureListener extends RotateGestureDetector.SimpleOnRotateGestureListener {
- private final float minimumScaleSpanWhenRotating;
- private final float angularVelocityMultiplier;
- private final float minimumAngularVelocity;
- private final double rotateVelocityRatioThreshold;
- private final float defaultSpanSinceStartThreshold;
-
- RotateGestureListener(float minimumScaleSpanWhenRotating, double densityMultiplier, float angularVelocityMultiplier,
- float minimumAngularVelocity, float defaultSpanSinceStartThreshold) {
- this.minimumScaleSpanWhenRotating = minimumScaleSpanWhenRotating;
- this.angularVelocityMultiplier = angularVelocityMultiplier;
- this.minimumAngularVelocity = minimumAngularVelocity;
- this.rotateVelocityRatioThreshold = ROTATE_VELOCITY_RATIO_THRESHOLD * densityMultiplier;
- this.defaultSpanSinceStartThreshold = defaultSpanSinceStartThreshold;
- }
-
- @Override
- public boolean onRotateBegin(@NonNull RotateGestureDetector detector) {
- if (!uiSettings.isRotateGesturesEnabled()) {
- return false;
- }
-
- float deltaSinceLast = Math.abs(detector.getDeltaSinceLast());
- double currTime = detector.getCurrentEvent().getEventTime();
- double prevTime = detector.getPreviousEvent().getEventTime();
- if (currTime == prevTime) {
- return false;
- }
- double speed = deltaSinceLast / (currTime - prevTime);
- float deltaSinceStart = Math.abs(detector.getDeltaSinceStart());
-
- // adjust the responsiveness of a rotation gesture - the higher the speed, the bigger the threshold
- if (speed < 0.04
- || (speed > 0.07 && deltaSinceStart < 5)
- || (speed > 0.15 && deltaSinceStart < 7)
- || (speed > 0.5 && deltaSinceStart < 15)
- ) {
- return false;
- }
-
- if (uiSettings.isIncreaseScaleThresholdWhenRotating()) {
- // when rotation starts, interrupting scale and increasing the threshold
- // to make rotation without scaling easier
- gesturesManager.getStandardScaleGestureDetector().setSpanSinceStartThreshold(minimumScaleSpanWhenRotating);
- gesturesManager.getStandardScaleGestureDetector().interrupt();
- }
-
- cancelTransitionsIfRequired();
-
- notifyOnRotateBeginListeners(detector);
-
- return true;
- }
-
- @Override
- public boolean onRotate(@NonNull RotateGestureDetector detector, float rotationDegreesSinceLast,
- float rotationDegreesSinceFirst) {
- // dispatching camera start event only when the movement actually occurred
- cameraChangeDispatcher.onCameraMoveStarted(CameraChangeDispatcher.REASON_API_GESTURE);
-
- // Calculate map bearing value
- double bearing = transform.getRawBearing() + rotationDegreesSinceLast;
-
- // Rotate the map
- PointF focalPoint = getRotateFocalPoint(detector);
- transform.setBearing(bearing, focalPoint.x, focalPoint.y);
-
- notifyOnRotateListeners(detector);
-
- return true;
- }
-
- @Override
- public void onRotateEnd(@NonNull RotateGestureDetector detector, float velocityX,
- float velocityY, float angularVelocity) {
- if (uiSettings.isIncreaseScaleThresholdWhenRotating()) {
- // resetting default scale threshold values
- gesturesManager.getStandardScaleGestureDetector().setSpanSinceStartThreshold(defaultSpanSinceStartThreshold);
- }
-
- notifyOnRotateEndListeners(detector);
-
- angularVelocity = angularVelocity * angularVelocityMultiplier;
- angularVelocity = MathUtils.clamp(angularVelocity, -MAXIMUM_ANGULAR_VELOCITY, MAXIMUM_ANGULAR_VELOCITY);
-
- float velocityXY = Math.abs(velocityX) + Math.abs(velocityY);
- float delta = Math.abs(detector.getDeltaSinceLast());
- double ratio = delta / velocityXY;
-
- if (!uiSettings.isRotateVelocityAnimationEnabled()
- || Math.abs(angularVelocity) < minimumAngularVelocity
- || (gesturesManager.getStandardScaleGestureDetector().isInProgress() && ratio < rotateVelocityRatioThreshold)) {
- // notifying listeners that camera is idle only if there is no follow-up animation
- dispatchCameraIdle();
- return;
- }
-
- long animationTime = (long) ((Math.log((Math.abs(angularVelocity)) + 1 / Math.pow(Math.E, 2)) + 2)
- * SCALE_VELOCITY_ANIMATION_DURATION_MULTIPLIER);
-
- PointF focalPoint = getRotateFocalPoint(detector);
- rotateAnimator = createRotateAnimator(angularVelocity, animationTime, focalPoint);
- scheduleAnimator(rotateAnimator);
- }
-
- @NonNull
- private PointF getRotateFocalPoint(@NonNull RotateGestureDetector detector) {
- if (constantFocalPoint != null) {
- // User provided focal point
- return constantFocalPoint;
- } else {
- // around gesture
- return detector.getFocalPoint();
- }
- }
-
- private Animator createRotateAnimator(float angularVelocity, long animationTime,
- @NonNull final PointF animationFocalPoint) {
- ValueAnimator animator = ValueAnimator.ofFloat(angularVelocity, 0f);
- animator.setDuration(animationTime);
- animator.setInterpolator(new DecelerateInterpolator());
- animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
- @Override
- public void onAnimationUpdate(@NonNull ValueAnimator animation) {
- transform.setBearing(
- transform.getRawBearing() + (float) animation.getAnimatedValue(),
- animationFocalPoint.x, animationFocalPoint.y,
- 0L
- );
- }
- });
-
- animator.addListener(new AnimatorListenerAdapter() {
-
- @Override
- public void onAnimationStart(Animator animation) {
- transform.cancelTransitions();
- cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
- }
-
- @Override
- public void onAnimationCancel(Animator animation) {
- transform.cancelTransitions();
- }
-
- @Override
- public void onAnimationEnd(Animator animation) {
- dispatchCameraIdle();
- }
- });
-
- return animator;
- }
- }
-
- private final class ShoveGestureListener extends ShoveGestureDetector.SimpleOnShoveGestureListener {
- @Override
- public boolean onShoveBegin(@NonNull ShoveGestureDetector detector) {
- if (!uiSettings.isTiltGesturesEnabled()) {
- return false;
- }
-
- cancelTransitionsIfRequired();
-
- // disabling move gesture during shove
- gesturesManager.getMoveGestureDetector().setEnabled(false);
-
- notifyOnShoveBeginListeners(detector);
-
- return true;
- }
-
- @Override
- public boolean onShove(@NonNull ShoveGestureDetector detector,
- float deltaPixelsSinceLast, float deltaPixelsSinceStart) {
- // dispatching camera start event only when the movement actually occurred
- cameraChangeDispatcher.onCameraMoveStarted(CameraChangeDispatcher.REASON_API_GESTURE);
-
- // Get tilt value (scale and clamp)
- double pitch = transform.getTilt();
- pitch -= MapboxConstants.SHOVE_PIXEL_CHANGE_FACTOR * deltaPixelsSinceLast;
- pitch = MathUtils.clamp(pitch, MapboxConstants.MINIMUM_TILT, MapboxConstants.MAXIMUM_TILT);
-
- // Tilt the map
- transform.setTilt(pitch);
-
- notifyOnShoveListeners(detector);
-
- return true;
- }
-
- @Override
- public void onShoveEnd(@NonNull ShoveGestureDetector detector, float velocityX, float velocityY) {
- dispatchCameraIdle();
-
- // re-enabling move gesture
- gesturesManager.getMoveGestureDetector().setEnabled(true);
-
- notifyOnShoveEndListeners(detector);
- }
- }
-
- private final class TapGestureListener implements MultiFingerTapGestureDetector.OnMultiFingerTapGestureListener {
- @Override
- public boolean onMultiFingerTap(@NonNull MultiFingerTapGestureDetector detector, int pointersCount) {
- if (!uiSettings.isZoomGesturesEnabled() || pointersCount != 2) {
- return false;
- }
-
- transform.cancelTransitions();
- cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
-
- PointF zoomFocalPoint;
- // Single finger double tap
- if (constantFocalPoint != null) {
- // User provided focal point
- zoomFocalPoint = constantFocalPoint;
- } else {
- // Zoom in on gesture
- zoomFocalPoint = detector.getFocalPoint();
- }
-
- zoomOutAnimated(zoomFocalPoint, false);
-
- return true;
- }
- }
-
- private Animator createScaleAnimator(double currentZoom, double zoomAddition,
- @NonNull final PointF animationFocalPoint, long animationTime) {
- ValueAnimator animator = ValueAnimator.ofFloat((float) currentZoom, (float) (currentZoom + zoomAddition));
- animator.setDuration(animationTime);
- animator.setInterpolator(new DecelerateInterpolator());
- animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
-
- @Override
- public void onAnimationUpdate(@NonNull ValueAnimator animation) {
- transform.setZoom((Float) animation.getAnimatedValue(), animationFocalPoint);
- }
- });
-
- animator.addListener(new AnimatorListenerAdapter() {
-
- @Override
- public void onAnimationStart(Animator animation) {
- transform.cancelTransitions();
- cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
- }
-
- @Override
- public void onAnimationCancel(Animator animation) {
- transform.cancelTransitions();
- }
-
- @Override
- public void onAnimationEnd(Animator animation) {
- dispatchCameraIdle();
- }
- });
- return animator;
- }
-
- /**
- * Zoom in by 1.
- *
- * @param zoomFocalPoint focal point of zoom animation
- * @param runImmediately if true, animation will be started right away, otherwise it will wait until
- * {@link MotionEvent#ACTION_UP} is registered.
- */
- void zoomInAnimated(@NonNull PointF zoomFocalPoint, boolean runImmediately) {
- zoomAnimated(true, zoomFocalPoint, runImmediately);
- }
-
- /**
- * Zoom out by 1.
- *
- * @param zoomFocalPoint focal point of zoom animation
- * @param runImmediately if true, animation will be started right away, otherwise it will wait until
- * {@link MotionEvent#ACTION_UP} is registered.
- */
- void zoomOutAnimated(@NonNull PointF zoomFocalPoint, boolean runImmediately) {
- zoomAnimated(false, zoomFocalPoint, runImmediately);
- }
-
- private void zoomAnimated(boolean zoomIn, @NonNull PointF zoomFocalPoint, boolean runImmediately) {
- //canceling here as well, because when using a button it will not be canceled automatically by onDown()
- cancelAnimator(scaleAnimator);
-
- double currentZoom = transform.getRawZoom();
- scaleAnimator = createScaleAnimator(
- currentZoom,
- zoomIn ? 1 : -1,
- zoomFocalPoint,
- MapboxConstants.ANIMATION_DURATION);
- if (runImmediately) {
- scaleAnimator.start();
- } else {
- scheduleAnimator(scaleAnimator);
- }
- }
-
- private void dispatchCameraIdle() {
- // we need to dispatch camera idle callback only if there is no other gestures in progress
- if (noGesturesInProgress()) {
- // invalidate the camera position, so that it's valid when fetched from the #onIdle event
- // and doesn't rely on the last frame being rendered
- transform.invalidateCameraPosition();
- cameraChangeDispatcher.onCameraIdle();
- }
- }
-
- private void cancelTransitionsIfRequired() {
- // we need to cancel core transitions only if there is no started gesture yet
- if (noGesturesInProgress()) {
- transform.cancelTransitions();
- }
- }
-
- private boolean noGesturesInProgress() {
- return (!uiSettings.isScrollGesturesEnabled() || !gesturesManager.getMoveGestureDetector().isInProgress())
- && (!uiSettings.isZoomGesturesEnabled() || !gesturesManager.getStandardScaleGestureDetector().isInProgress())
- && (!uiSettings.isRotateGesturesEnabled() || !gesturesManager.getRotateGestureDetector().isInProgress())
- && (!uiSettings.isTiltGesturesEnabled() || !gesturesManager.getShoveGestureDetector().isInProgress());
- }
-
- void notifyOnMapClickListeners(@NonNull PointF tapPoint) {
- for (MapboxMap.OnMapClickListener listener : onMapClickListenerList) {
- if (listener.onMapClick(projection.fromScreenLocation(tapPoint))) {
- return;
- }
- }
- }
-
- void notifyOnMapLongClickListeners(@NonNull PointF longClickPoint) {
- for (MapboxMap.OnMapLongClickListener listener : onMapLongClickListenerList) {
- if (listener.onMapLongClick(projection.fromScreenLocation(longClickPoint))) {
- return;
- }
- }
- }
-
- void notifyOnFlingListeners() {
- for (MapboxMap.OnFlingListener listener : onFlingListenerList) {
- listener.onFling();
- }
- }
-
- void notifyOnMoveBeginListeners(@NonNull MoveGestureDetector detector) {
- for (MapboxMap.OnMoveListener listener : onMoveListenerList) {
- listener.onMoveBegin(detector);
- }
- }
-
- void notifyOnMoveListeners(@NonNull MoveGestureDetector detector) {
- for (MapboxMap.OnMoveListener listener : onMoveListenerList) {
- listener.onMove(detector);
- }
- }
-
- void notifyOnMoveEndListeners(@NonNull MoveGestureDetector detector) {
- for (MapboxMap.OnMoveListener listener : onMoveListenerList) {
- listener.onMoveEnd(detector);
- }
- }
-
- void notifyOnRotateBeginListeners(@NonNull RotateGestureDetector detector) {
- for (MapboxMap.OnRotateListener listener : onRotateListenerList) {
- listener.onRotateBegin(detector);
- }
- }
-
- void notifyOnRotateListeners(@NonNull RotateGestureDetector detector) {
- for (MapboxMap.OnRotateListener listener : onRotateListenerList) {
- listener.onRotate(detector);
- }
- }
-
- void notifyOnRotateEndListeners(@NonNull RotateGestureDetector detector) {
- for (MapboxMap.OnRotateListener listener : onRotateListenerList) {
- listener.onRotateEnd(detector);
- }
- }
-
- void notifyOnScaleBeginListeners(@NonNull StandardScaleGestureDetector detector) {
- for (MapboxMap.OnScaleListener listener : onScaleListenerList) {
- listener.onScaleBegin(detector);
- }
- }
-
- void notifyOnScaleListeners(@NonNull StandardScaleGestureDetector detector) {
- for (MapboxMap.OnScaleListener listener : onScaleListenerList) {
- listener.onScale(detector);
- }
- }
-
- void notifyOnScaleEndListeners(@NonNull StandardScaleGestureDetector detector) {
- for (MapboxMap.OnScaleListener listener : onScaleListenerList) {
- listener.onScaleEnd(detector);
- }
- }
-
- void notifyOnShoveBeginListeners(@NonNull ShoveGestureDetector detector) {
- for (MapboxMap.OnShoveListener listener : onShoveListenerList) {
- listener.onShoveBegin(detector);
- }
- }
-
- void notifyOnShoveListeners(@NonNull ShoveGestureDetector detector) {
- for (MapboxMap.OnShoveListener listener : onShoveListenerList) {
- listener.onShove(detector);
- }
- }
-
- void notifyOnShoveEndListeners(@NonNull ShoveGestureDetector detector) {
- for (MapboxMap.OnShoveListener listener : onShoveListenerList) {
- listener.onShoveEnd(detector);
- }
- }
-
- void addOnMapClickListener(MapboxMap.OnMapClickListener onMapClickListener) {
- onMapClickListenerList.add(onMapClickListener);
- }
-
- void removeOnMapClickListener(MapboxMap.OnMapClickListener onMapClickListener) {
- onMapClickListenerList.remove(onMapClickListener);
- }
-
- void addOnMapLongClickListener(MapboxMap.OnMapLongClickListener onMapLongClickListener) {
- onMapLongClickListenerList.add(onMapLongClickListener);
- }
-
- void removeOnMapLongClickListener(MapboxMap.OnMapLongClickListener onMapLongClickListener) {
- onMapLongClickListenerList.remove(onMapLongClickListener);
- }
-
- void addOnFlingListener(MapboxMap.OnFlingListener onFlingListener) {
- onFlingListenerList.add(onFlingListener);
- }
-
- void removeOnFlingListener(MapboxMap.OnFlingListener onFlingListener) {
- onFlingListenerList.remove(onFlingListener);
- }
-
- void addOnMoveListener(MapboxMap.OnMoveListener listener) {
- onMoveListenerList.add(listener);
- }
-
- void removeOnMoveListener(MapboxMap.OnMoveListener listener) {
- onMoveListenerList.remove(listener);
- }
-
- void addOnRotateListener(MapboxMap.OnRotateListener listener) {
- onRotateListenerList.add(listener);
- }
-
- void removeOnRotateListener(MapboxMap.OnRotateListener listener) {
- onRotateListenerList.remove(listener);
- }
-
- void addOnScaleListener(MapboxMap.OnScaleListener listener) {
- onScaleListenerList.add(listener);
- }
-
- void removeOnScaleListener(MapboxMap.OnScaleListener listener) {
- onScaleListenerList.remove(listener);
- }
-
- void addShoveListener(MapboxMap.OnShoveListener listener) {
- onShoveListenerList.add(listener);
- }
-
- void removeShoveListener(MapboxMap.OnShoveListener listener) {
- onShoveListenerList.remove(listener);
- }
-
- AndroidGesturesManager getGesturesManager() {
- return gesturesManager;
- }
-
- void setGesturesManager(@NonNull Context context, @NonNull AndroidGesturesManager gesturesManager,
- boolean attachDefaultListeners, boolean setDefaultMutuallyExclusives) {
- initializeGesturesManager(gesturesManager, setDefaultMutuallyExclusives);
- initializeGestureListeners(context, attachDefaultListeners);
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java
deleted file mode 100644
index afb80027d9..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java
+++ /dev/null
@@ -1,271 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.graphics.PointF;
-import android.os.Handler;
-import android.os.Looper;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-import android.view.ViewConfiguration;
-
-/**
- * Manages key events on a MapView.
- * <p>
- * <ul>
- * <li> Uses {@link Transform} to change the map state</li>
- * <li> Uses {@link UiSettings} to verify validity of user restricted movement.</li>
- * </ul>
- * <p>
- */
-final class MapKeyListener {
-
- private final Transform transform;
- private final UiSettings uiSettings;
- private final MapGestureDetector mapGestureDetector;
-
- @Nullable
- private TrackballLongPressTimeOut currentTrackballLongPressTimeOut;
-
- MapKeyListener(Transform transform, UiSettings uiSettings, MapGestureDetector mapGestureDetector) {
- this.transform = transform;
- this.uiSettings = uiSettings;
- this.mapGestureDetector = mapGestureDetector;
- }
-
- /**
- * Called when the user presses a key, alse called for repeated keys held down.
- *
- * @param keyCode the id of the pressed key
- * @param event the related key event
- * @return true if the wevent is handled
- */
- boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
- // If the user has held the scroll key down for a while then accelerate
- // the scroll speed
- double scrollDist = event.getRepeatCount() >= 5 ? 50.0 : 10.0;
-
- // Check which key was pressed via hardware/real key code
- switch (keyCode) {
- // Tell the system to track these keys for long presses on
- // onKeyLongPress is fired
- case KeyEvent.KEYCODE_ENTER:
- case KeyEvent.KEYCODE_DPAD_CENTER:
- event.startTracking();
- return true;
-
- case KeyEvent.KEYCODE_DPAD_LEFT:
- if (!uiSettings.isScrollGesturesEnabled()) {
- return false;
- }
-
- // Cancel any animation
- transform.cancelTransitions();
-
- // Move left
- transform.moveBy(scrollDist, 0.0, 0 /*no animation*/);
- return true;
-
- case KeyEvent.KEYCODE_DPAD_RIGHT:
- if (!uiSettings.isScrollGesturesEnabled()) {
- return false;
- }
-
- // Cancel any animation
- transform.cancelTransitions();
-
- // Move right
- transform.moveBy(-scrollDist, 0.0, 0 /*no animation*/);
- return true;
-
- case KeyEvent.KEYCODE_DPAD_UP:
- if (!uiSettings.isScrollGesturesEnabled()) {
- return false;
- }
-
- // Cancel any animation
- transform.cancelTransitions();
-
- // Move up
- transform.moveBy(0.0, scrollDist, 0 /*no animation*/);
- return true;
-
- case KeyEvent.KEYCODE_DPAD_DOWN:
- if (!uiSettings.isScrollGesturesEnabled()) {
- return false;
- }
-
- // Cancel any animation
- transform.cancelTransitions();
-
- // Move down
- transform.moveBy(0.0, -scrollDist, 0 /*no animation*/);
- return true;
-
- default:
- // We are not interested in this key
- return false;
- }
- }
-
- /**
- * Called when the user long presses a key that is being tracked.
- *
- * @param keyCode the id of the long pressed key
- * @param event the related key event
- * @return true if event is handled
- */
- boolean onKeyLongPress(int keyCode, KeyEvent event) {
- // Check which key was pressed via hardware/real key code
- switch (keyCode) {
- // Tell the system to track these keys for long presses on
- // onKeyLongPress is fired
- case KeyEvent.KEYCODE_ENTER:
- case KeyEvent.KEYCODE_DPAD_CENTER:
- if (!uiSettings.isZoomGesturesEnabled()) {
- return false;
- }
-
- // Zoom out
- PointF focalPoint = new PointF(uiSettings.getWidth() / 2, uiSettings.getHeight() / 2);
- mapGestureDetector.zoomOutAnimated(focalPoint, true);
- return true;
-
- default:
- // We are not interested in this key
- return false;
- }
- }
-
- /**
- * Called when the user releases a key.
- *
- * @param keyCode the id of the released key
- * @param event the related key event
- * @return true if the event is handled
- */
- boolean onKeyUp(int keyCode, KeyEvent event) {
- // Check if the key action was canceled (used for virtual keyboards)
- if (event.isCanceled()) {
- return false;
- }
-
- // Check which key was pressed via hardware/real key code
- // Note if keyboard does not have physical key (ie primary non-shifted
- // key) then it will not appear here
- // Must use the key character map as physical to character is not
- // fixed/guaranteed
- switch (keyCode) {
- case KeyEvent.KEYCODE_ENTER:
- case KeyEvent.KEYCODE_DPAD_CENTER:
- if (!uiSettings.isZoomGesturesEnabled()) {
- return false;
- }
-
- // Zoom in
- PointF focalPoint = new PointF(uiSettings.getWidth() / 2, uiSettings.getHeight() / 2);
- mapGestureDetector.zoomInAnimated(focalPoint, true);
- return true;
- }
-
- // We are not interested in this key
- return false;
- }
-
- /**
- * Called for trackball events, all motions are relative in device specific units.
- *
- * @param event the related motion event
- * @return true if the event is handled
- */
- boolean onTrackballEvent(MotionEvent event) {
- // Choose the action
- switch (event.getActionMasked()) {
- // The trackball was rotated
- case MotionEvent.ACTION_MOVE:
- if (!uiSettings.isScrollGesturesEnabled()) {
- return false;
- }
-
- // Cancel any animation
- transform.cancelTransitions();
-
- // Scroll the map
- transform.moveBy(-10.0 * event.getX(), -10.0 * event.getY(), 0 /*no animation*/);
- return true;
-
- // Trackball was pushed in so start tracking and tell system we are
- // interested
- // We will then get the up action
- case MotionEvent.ACTION_DOWN:
- // Set up a delayed callback to check if trackball is still
- // After waiting the system long press time out
- if (currentTrackballLongPressTimeOut != null) {
- currentTrackballLongPressTimeOut.cancel();
- currentTrackballLongPressTimeOut = null;
- }
- currentTrackballLongPressTimeOut = new TrackballLongPressTimeOut();
- new Handler(Looper.getMainLooper()).postDelayed(currentTrackballLongPressTimeOut,
- ViewConfiguration.getLongPressTimeout());
- return true;
-
- // Trackball was released
- case MotionEvent.ACTION_UP:
- if (!uiSettings.isZoomGesturesEnabled()) {
- return false;
- }
-
- // Only handle if we have not already long pressed
- if (currentTrackballLongPressTimeOut != null) {
- // Zoom in
- PointF focalPoint = new PointF(uiSettings.getWidth() / 2, uiSettings.getHeight() / 2);
- mapGestureDetector.zoomInAnimated(focalPoint, true);
- }
- return true;
-
- // Trackball was cancelled
- case MotionEvent.ACTION_CANCEL:
- if (currentTrackballLongPressTimeOut != null) {
- currentTrackballLongPressTimeOut.cancel();
- currentTrackballLongPressTimeOut = null;
- }
- return true;
-
- default:
- // We are not interested in this event
- return false;
- }
- }
-
- /**
- * This class implements the trackball long press time out callback
- */
- private class TrackballLongPressTimeOut implements Runnable {
-
- // Track if we have been cancelled
- private boolean cancelled;
-
- TrackballLongPressTimeOut() {
- cancelled = false;
- }
-
- // Cancel the timeout
- public void cancel() {
- cancelled = true;
- }
-
- // Called when long press time out expires
- @Override
- public void run() {
- // Check if the trackball is still pressed
- if (!cancelled) {
- // Zoom out
- PointF pointF = new PointF(uiSettings.getWidth() / 2, uiSettings.getHeight() / 2);
- mapGestureDetector.zoomOutAnimated(pointF, true);
-
- // Ensure the up action is not run
- currentTrackballLongPressTimeOut = null;
- }
- }
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
deleted file mode 100644
index 4521d2ae60..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
+++ /dev/null
@@ -1,1350 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.PointF;
-import android.graphics.drawable.ColorDrawable;
-import android.os.Bundle;
-import android.support.annotation.CallSuper;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.annotation.UiThread;
-import android.support.v4.util.LongSparseArray;
-import android.util.AttributeSet;
-import android.view.KeyEvent;
-import android.view.LayoutInflater;
-import android.view.MotionEvent;
-import android.view.TextureView;
-import android.view.View;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
-
-import com.mapbox.android.gestures.AndroidGesturesManager;
-import com.mapbox.mapboxsdk.MapStrictMode;
-import com.mapbox.mapboxsdk.Mapbox;
-import com.mapbox.mapboxsdk.R;
-import com.mapbox.mapboxsdk.annotations.Annotation;
-import com.mapbox.mapboxsdk.constants.MapboxConstants;
-import com.mapbox.mapboxsdk.exceptions.MapboxConfigurationException;
-import com.mapbox.mapboxsdk.location.LocationComponent;
-import com.mapbox.mapboxsdk.maps.renderer.MapRenderer;
-import com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.GLSurfaceViewMapRenderer;
-import com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.MapboxGLSurfaceView;
-import com.mapbox.mapboxsdk.maps.renderer.textureview.TextureViewMapRenderer;
-import com.mapbox.mapboxsdk.maps.widgets.CompassView;
-import com.mapbox.mapboxsdk.net.ConnectivityReceiver;
-import com.mapbox.mapboxsdk.storage.FileSource;
-import com.mapbox.mapboxsdk.utils.BitmapUtils;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.microedition.khronos.egl.EGLConfig;
-import javax.microedition.khronos.opengles.GL10;
-
-import static com.mapbox.mapboxsdk.maps.widgets.CompassView.TIME_MAP_NORTH_ANIMATION;
-import static com.mapbox.mapboxsdk.maps.widgets.CompassView.TIME_WAIT_IDLE;
-
-/**
- * <p>
- * A {@code MapView} provides an embeddable map interface.
- * You use this class to display map information and to manipulate the map contents from your application.
- * You can center the map on a given coordinate, specify the size of the area you want to display,
- * and style the features of the map to fit your application's use case.
- * </p>
- * <p>
- * Use of {@code MapView} requires a Mapbox API access token.
- * Obtain an access token on the <a href="https://www.mapbox.com/studio/account/tokens/">Mapbox account page</a>.
- * </p>
- * <strong>Warning:</strong> Please note that you are responsible for getting permission to use the map data,
- * and for ensuring your use adheres to the relevant terms of use.
- */
-public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
-
- private final MapChangeReceiver mapChangeReceiver = new MapChangeReceiver();
- private final MapCallback mapCallback = new MapCallback();
- private final InitialRenderCallback initialRenderCallback = new InitialRenderCallback();
-
- @Nullable
- private NativeMap nativeMapView;
- @Nullable
- private MapboxMap mapboxMap;
- private AttributionClickListener attributionClickListener;
- private MapboxMapOptions mapboxMapOptions;
- private MapRenderer mapRenderer;
- private boolean destroyed;
-
- private CompassView compassView;
- private PointF focalPoint;
- private ImageView attrView;
- private ImageView logoView;
-
- @Nullable
- private MapGestureDetector mapGestureDetector;
- @Nullable
- private MapKeyListener mapKeyListener;
- @Nullable
- private Bundle savedInstanceState;
- private boolean isStarted;
-
- @UiThread
- public MapView(@NonNull Context context) {
- super(context);
- initialize(context, MapboxMapOptions.createFromAttributes(context));
- }
-
- @UiThread
- public MapView(@NonNull Context context, @Nullable AttributeSet attrs) {
- super(context, attrs);
- initialize(context, MapboxMapOptions.createFromAttributes(context, attrs));
- }
-
- @UiThread
- public MapView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- initialize(context, MapboxMapOptions.createFromAttributes(context, attrs));
- }
-
- @UiThread
- public MapView(@NonNull Context context, @Nullable MapboxMapOptions options) {
- super(context);
- initialize(context, options == null ? MapboxMapOptions.createFromAttributes(context) : options);
- }
-
- @CallSuper
- @UiThread
- protected void initialize(@NonNull final Context context, @NonNull final MapboxMapOptions options) {
- if (isInEditMode()) {
- // in IDE layout editor, just return
- return;
- }
-
- if (!Mapbox.hasInstance()) {
- throw new MapboxConfigurationException();
- }
-
- // hide surface until map is fully loaded #10990
- setForeground(new ColorDrawable(options.getForegroundLoadColor()));
-
- mapboxMapOptions = options;
-
- // inflate view
- View view = LayoutInflater.from(context).inflate(R.layout.mapbox_mapview_internal, this);
- compassView = view.findViewById(R.id.compassView);
- attrView = view.findViewById(R.id.attributionView);
- attrView.setImageDrawable(BitmapUtils.getDrawableFromRes(getContext(), R.drawable.mapbox_info_bg_selector));
- logoView = view.findViewById(R.id.logoView);
- logoView.setImageDrawable(BitmapUtils.getDrawableFromRes(getContext(), R.drawable.mapbox_logo_icon));
-
- // add accessibility support
- setContentDescription(context.getString(R.string.mapbox_mapActionDescription));
- setWillNotDraw(false);
- initialiseDrawingSurface(options);
- }
-
- private void initialiseMap() {
- Context context = getContext();
-
- // callback for focal point invalidation
- final FocalPointInvalidator focalInvalidator = new FocalPointInvalidator();
- focalInvalidator.addListener(createFocalPointChangeListener());
-
- // callback for registering touch listeners
- GesturesManagerInteractionListener registerTouchListener = new GesturesManagerInteractionListener();
-
- // callback for camera change events
- final CameraChangeDispatcher cameraDispatcher = new CameraChangeDispatcher();
-
- // setup components for MapboxMap creation
- Projection proj = new Projection(nativeMapView, this);
- UiSettings uiSettings = new UiSettings(proj, focalInvalidator, compassView, attrView, logoView, getPixelRatio());
- LongSparseArray<Annotation> annotationsArray = new LongSparseArray<>();
- IconManager iconManager = new IconManager(nativeMapView);
- Annotations annotations = new AnnotationContainer(nativeMapView, annotationsArray);
- Markers markers = new MarkerContainer(nativeMapView, annotationsArray, iconManager);
- Polygons polygons = new PolygonContainer(nativeMapView, annotationsArray);
- Polylines polylines = new PolylineContainer(nativeMapView, annotationsArray);
- ShapeAnnotations shapeAnnotations = new ShapeAnnotationContainer(nativeMapView, annotationsArray);
- AnnotationManager annotationManager = new AnnotationManager(this, annotationsArray, iconManager,
- annotations, markers, polygons, polylines, shapeAnnotations);
- Transform transform = new Transform(this, nativeMapView, cameraDispatcher);
-
- // MapboxMap
- List<MapboxMap.OnDeveloperAnimationListener> developerAnimationListeners = new ArrayList<>();
- mapboxMap = new MapboxMap(nativeMapView, transform, uiSettings, proj, registerTouchListener, cameraDispatcher,
- developerAnimationListeners);
- mapboxMap.injectAnnotationManager(annotationManager);
-
- // user input
- mapGestureDetector = new MapGestureDetector(context, transform, proj, uiSettings,
- annotationManager, cameraDispatcher);
- mapKeyListener = new MapKeyListener(transform, uiSettings, mapGestureDetector);
-
- // compass
- compassView.injectCompassAnimationListener(createCompassAnimationListener(cameraDispatcher));
- compassView.setOnClickListener(createCompassClickListener(cameraDispatcher));
-
- // LocationComponent
- mapboxMap.injectLocationComponent(new LocationComponent(mapboxMap, transform, developerAnimationListeners));
-
- // inject widgets with MapboxMap
- attrView.setOnClickListener(attributionClickListener = new AttributionClickListener(context, mapboxMap));
-
- // Ensure this view is interactable
- setClickable(true);
- setLongClickable(true);
- setFocusable(true);
- setFocusableInTouchMode(true);
- requestDisallowInterceptTouchEvent(true);
-
- // notify Map object about current connectivity state
- nativeMapView.setReachability(Mapbox.isConnected());
-
- // initialise MapboxMap
- if (savedInstanceState == null) {
- mapboxMap.initialise(context, mapboxMapOptions);
- } else {
- mapboxMap.onRestoreInstanceState(savedInstanceState);
- }
-
- mapCallback.initialised();
- }
-
- private FocalPointChangeListener createFocalPointChangeListener() {
- return new FocalPointChangeListener() {
- @Override
- public void onFocalPointChanged(PointF pointF) {
- focalPoint = pointF;
- }
- };
- }
-
- private MapboxMap.OnCompassAnimationListener createCompassAnimationListener(@NonNull final CameraChangeDispatcher
- cameraChangeDispatcher) {
- return new MapboxMap.OnCompassAnimationListener() {
- @Override
- public void onCompassAnimation() {
- cameraChangeDispatcher.onCameraMove();
- }
-
- @Override
- public void onCompassAnimationFinished() {
- compassView.isAnimating(false);
- cameraChangeDispatcher.onCameraIdle();
- }
- };
- }
-
- private OnClickListener createCompassClickListener(@NonNull final CameraChangeDispatcher cameraChangeDispatcher) {
- return new OnClickListener() {
- @Override
- public void onClick(View v) {
- if (mapboxMap != null && compassView != null) {
- if (focalPoint != null) {
- mapboxMap.setFocalBearing(0, focalPoint.x, focalPoint.y, TIME_MAP_NORTH_ANIMATION);
- } else {
- mapboxMap.setFocalBearing(0, mapboxMap.getWidth() / 2, mapboxMap.getHeight() / 2, TIME_MAP_NORTH_ANIMATION);
- }
- cameraChangeDispatcher.onCameraMoveStarted(MapboxMap.OnCameraMoveStartedListener.REASON_API_ANIMATION);
- compassView.isAnimating(true);
- compassView.postDelayed(compassView, TIME_WAIT_IDLE + TIME_MAP_NORTH_ANIMATION);
- }
- }
- };
- }
-
- //
- // Lifecycle events
- //
-
- /**
- * <p>
- * You must call this method from the parent's Activity#onCreate(Bundle)} or
- * Fragment#onViewCreated(View, Bundle).
- * </p>
- * You must set a valid access token with {@link com.mapbox.mapboxsdk.Mapbox#getInstance(Context, String)}
- * before you call this method or an exception will be thrown.
- *
- * @param savedInstanceState Pass in the parent's savedInstanceState.
- * @see com.mapbox.mapboxsdk.Mapbox#getInstance(Context, String)
- */
- @UiThread
- public void onCreate(@Nullable Bundle savedInstanceState) {
- if (savedInstanceState == null) {
- TelemetryDefinition telemetry = Mapbox.getTelemetry();
- if (telemetry != null) {
- telemetry.onAppUserTurnstileEvent();
- }
- } else if (savedInstanceState.getBoolean(MapboxConstants.STATE_HAS_SAVED_STATE)) {
- this.savedInstanceState = savedInstanceState;
- }
- }
-
- private void initialiseDrawingSurface(MapboxMapOptions options) {
- String localFontFamily = options.getLocalIdeographFontFamily();
- if (options.getTextureMode()) {
- TextureView textureView = new TextureView(getContext());
- boolean translucentSurface = options.getTranslucentTextureSurface();
- mapRenderer = new TextureViewMapRenderer(getContext(),
- textureView, localFontFamily, translucentSurface) {
- @Override
- protected void onSurfaceCreated(GL10 gl, EGLConfig config) {
- MapView.this.onSurfaceCreated();
- super.onSurfaceCreated(gl, config);
- }
- };
-
- addView(textureView, 0);
- } else {
- MapboxGLSurfaceView glSurfaceView = new MapboxGLSurfaceView(getContext());
- glSurfaceView.setZOrderMediaOverlay(mapboxMapOptions.getRenderSurfaceOnTop());
- mapRenderer = new GLSurfaceViewMapRenderer(getContext(), glSurfaceView, localFontFamily) {
- @Override
- public void onSurfaceCreated(GL10 gl, EGLConfig config) {
- MapView.this.onSurfaceCreated();
- super.onSurfaceCreated(gl, config);
- }
- };
-
- addView(glSurfaceView, 0);
- }
-
- boolean crossSourceCollisions = mapboxMapOptions.getCrossSourceCollisions();
- nativeMapView = new NativeMapView(
- getContext(), getPixelRatio(), crossSourceCollisions, this, mapChangeReceiver, mapRenderer
- );
- }
-
- private void onSurfaceCreated() {
- post(new Runnable() {
- @Override
- public void run() {
- // Initialise only when not destroyed and only once
- if (!destroyed && mapboxMap == null) {
- MapView.this.initialiseMap();
- mapboxMap.onStart();
- }
- }
- });
- }
-
- /**
- * You must call this method from the parent's Activity#onSaveInstanceState(Bundle)
- * or Fragment#onSaveInstanceState(Bundle).
- *
- * @param outState Pass in the parent's outState.
- */
- @UiThread
- public void onSaveInstanceState(@NonNull Bundle outState) {
- if (mapboxMap != null) {
- outState.putBoolean(MapboxConstants.STATE_HAS_SAVED_STATE, true);
- mapboxMap.onSaveInstanceState(outState);
- }
- }
-
- /**
- * You must call this method from the parent's Activity#onStart() or Fragment#onStart()
- */
- @UiThread
- public void onStart() {
- if (!isStarted) {
- ConnectivityReceiver.instance(getContext()).activate();
- FileSource.getInstance(getContext()).activate();
- isStarted = true;
- }
- if (mapboxMap != null) {
- mapboxMap.onStart();
- }
-
- if (mapRenderer != null) {
- mapRenderer.onStart();
- }
- }
-
- /**
- * You must call this method from the parent's Activity#onResume() or Fragment#onResume().
- */
- @UiThread
- public void onResume() {
- if (mapRenderer != null) {
- mapRenderer.onResume();
- }
- }
-
- /**
- * You must call this method from the parent's Activity#onPause() or Fragment#onPause().
- */
- @UiThread
- public void onPause() {
- if (mapRenderer != null) {
- mapRenderer.onPause();
- }
- }
-
- /**
- * You must call this method from the parent's Activity#onStop() or Fragment#onStop().
- */
- @UiThread
- public void onStop() {
- if (attributionClickListener != null) {
- attributionClickListener.onStop();
- }
-
- if (mapboxMap != null) {
- // map was destroyed before it was started
- mapGestureDetector.cancelAnimators();
- mapboxMap.onStop();
- }
-
- if (mapRenderer != null) {
- mapRenderer.onStop();
- }
-
- if (isStarted) {
- ConnectivityReceiver.instance(getContext()).deactivate();
- FileSource.getInstance(getContext()).deactivate();
- isStarted = false;
- }
- }
-
- /**
- * You must call this method from the parent's Activity#onDestroy() or Fragment#onDestroyView().
- */
- @UiThread
- public void onDestroy() {
- destroyed = true;
- mapChangeReceiver.clear();
- mapCallback.onDestroy();
- initialRenderCallback.onDestroy();
-
- if (compassView != null) {
- // avoid leaking context through animator #13742
- compassView.resetAnimation();
- }
-
- if (mapboxMap != null) {
- mapboxMap.onDestroy();
- }
-
- if (nativeMapView != null) {
- // null when destroying an activity programmatically mapbox-navigation-android/issues/503
- nativeMapView.destroy();
- nativeMapView = null;
- }
-
- if (mapRenderer != null) {
- mapRenderer.onDestroy();
- }
- }
-
- /**
- * The maximum frame rate at which the map view is rendered,
- * but it can't excess the ability of device hardware.
- *
- * @param maximumFps Can be set to arbitrary integer values.
- */
- public void setMaximumFps(int maximumFps) {
- if (mapRenderer != null) {
- mapRenderer.setMaximumFps(maximumFps);
- } else {
- throw new IllegalStateException("Calling MapView#setMaximumFps before mapRenderer is created.");
- }
- }
-
- /**
- * Returns if the map has been destroyed.
- * <p>
- * This method can be used to determine if the result of an asynchronous operation should be set.
- * </p>
- *
- * @return true, if the map has been destroyed
- */
- @UiThread
- public boolean isDestroyed() {
- return destroyed;
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- if (!isGestureDetectorInitialized()) {
- return super.onTouchEvent(event);
- }
-
- return mapGestureDetector.onTouchEvent(event) || super.onTouchEvent(event);
- }
-
- @Override
- public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
- return mapKeyListener.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event);
- }
-
- @Override
- public boolean onKeyLongPress(int keyCode, KeyEvent event) {
- return mapKeyListener.onKeyLongPress(keyCode, event) || super.onKeyLongPress(keyCode, event);
- }
-
- @Override
- public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) {
- return mapKeyListener.onKeyUp(keyCode, event) || super.onKeyUp(keyCode, event);
- }
-
- @Override
- public boolean onTrackballEvent(@NonNull MotionEvent event) {
- return mapKeyListener.onTrackballEvent(event) || super.onTrackballEvent(event);
- }
-
- @Override
- public boolean onGenericMotionEvent(@NonNull MotionEvent event) {
- if (!isGestureDetectorInitialized()) {
- return super.onGenericMotionEvent(event);
- }
- return mapGestureDetector.onGenericMotionEvent(event) || super.onGenericMotionEvent(event);
- }
-
- /**
- * You must call this method from the parent's Activity#onLowMemory() or Fragment#onLowMemory().
- */
- @UiThread
- public void onLowMemory() {
- if (nativeMapView != null && mapboxMap != null && !destroyed) {
- nativeMapView.onLowMemory();
- }
- }
-
- //
- // Rendering
- //
-
- @Override
- protected void onSizeChanged(int width, int height, int oldw, int oldh) {
- if (!isInEditMode() && nativeMapView != null) {
- // null-checking the nativeMapView, see #13277
- nativeMapView.resizeView(width, height);
- }
- }
-
- private float getPixelRatio() {
- // check is user defined his own pixel ratio value
- float pixelRatio = mapboxMapOptions.getPixelRatio();
- if (pixelRatio == 0) {
- // if not, get the one defined by the system
- pixelRatio = getResources().getDisplayMetrics().density;
- }
- return pixelRatio;
- }
-
- //
- // ViewCallback
- //
-
- @Nullable
- @Override
- public Bitmap getViewContent() {
- return BitmapUtils.createBitmapFromView(this);
- }
-
- //
- // Map events
- //
-
- /**
- * Set a callback that's invoked when the camera region will change.
- *
- * @param listener The callback that's invoked when the camera region will change
- */
- public void addOnCameraWillChangeListener(@NonNull OnCameraWillChangeListener listener) {
- mapChangeReceiver.addOnCameraWillChangeListener(listener);
- }
-
- /**
- * Remove a callback that's invoked when the camera region will change.
- *
- * @param listener The callback that's invoked when the camera region will change
- */
- public void removeOnCameraWillChangeListener(@NonNull OnCameraWillChangeListener listener) {
- mapChangeReceiver.removeOnCameraWillChangeListener(listener);
- }
-
- /**
- * Set a callback that's invoked when the camera is changing.
- *
- * @param listener The callback that's invoked when the camera is changing
- */
- public void addOnCameraIsChangingListener(@NonNull OnCameraIsChangingListener listener) {
- mapChangeReceiver.addOnCameraIsChangingListener(listener);
- }
-
- /**
- * Remove a callback that's invoked when the camera is changing.
- *
- * @param listener The callback that's invoked when the camera is changing
- */
- public void removeOnCameraIsChangingListener(@NonNull OnCameraIsChangingListener listener) {
- mapChangeReceiver.removeOnCameraIsChangingListener(listener);
- }
-
- /**
- * Set a callback that's invoked when the camera region did change.
- *
- * @param listener The callback that's invoked when the camera region did change
- */
- public void addOnCameraDidChangeListener(@NonNull OnCameraDidChangeListener listener) {
- mapChangeReceiver.addOnCameraDidChangeListener(listener);
- }
-
- /**
- * Set a callback that's invoked when the camera region did change.
- *
- * @param listener The callback that's invoked when the camera region did change
- */
- public void removeOnCameraDidChangeListener(@NonNull OnCameraDidChangeListener listener) {
- mapChangeReceiver.removeOnCameraDidChangeListener(listener);
- }
-
- /**
- * Set a callback that's invoked when the map will start loading.
- *
- * @param listener The callback that's invoked when the map will start loading
- */
- public void addOnWillStartLoadingMapListener(@NonNull OnWillStartLoadingMapListener listener) {
- mapChangeReceiver.addOnWillStartLoadingMapListener(listener);
- }
-
- /**
- * Set a callback that's invoked when the map will start loading.
- *
- * @param listener The callback that's invoked when the map will start loading
- */
- public void removeOnWillStartLoadingMapListener(@NonNull OnWillStartLoadingMapListener listener) {
- mapChangeReceiver.removeOnWillStartLoadingMapListener(listener);
- }
-
- /**
- * Set a callback that's invoked when the map has finished loading.
- *
- * @param listener The callback that's invoked when the map has finished loading
- */
- public void addOnDidFinishLoadingMapListener(@NonNull OnDidFinishLoadingMapListener listener) {
- mapChangeReceiver.addOnDidFinishLoadingMapListener(listener);
- }
-
- /**
- * Set a callback that's invoked when the map has finished loading.
- *
- * @param listener The callback that's invoked when the map has finished loading
- */
- public void removeOnDidFinishLoadingMapListener(@NonNull OnDidFinishLoadingMapListener listener) {
- mapChangeReceiver.removeOnDidFinishLoadingMapListener(listener);
- }
-
- /**
- * Set a callback that's invoked when the map failed to load.
- *
- * @param listener The callback that's invoked when the map failed to load
- */
- public void addOnDidFailLoadingMapListener(@NonNull OnDidFailLoadingMapListener listener) {
- mapChangeReceiver.addOnDidFailLoadingMapListener(listener);
- }
-
- /**
- * Set a callback that's invoked when the map failed to load.
- *
- * @param listener The callback that's invoked when the map failed to load
- */
- public void removeOnDidFailLoadingMapListener(@NonNull OnDidFailLoadingMapListener listener) {
- mapChangeReceiver.removeOnDidFailLoadingMapListener(listener);
- }
-
- /**
- * Set a callback that's invoked when the map will start rendering a frame.
- *
- * @param listener The callback that's invoked when the camera will start rendering a frame
- */
- public void addOnWillStartRenderingFrameListener(@NonNull OnWillStartRenderingFrameListener listener) {
- mapChangeReceiver.addOnWillStartRenderingFrameListener(listener);
- }
-
- /**
- * Set a callback that's invoked when the map will start rendering a frame.
- *
- * @param listener The callback that's invoked when the camera will start rendering a frame
- */
- public void removeOnWillStartRenderingFrameListener(@NonNull OnWillStartRenderingFrameListener listener) {
- mapChangeReceiver.removeOnWillStartRenderingFrameListener(listener);
- }
-
- /**
- * Set a callback that's invoked when the map has finished rendering a frame.
- *
- * @param listener The callback that's invoked when the map has finished rendering a frame
- */
- public void addOnDidFinishRenderingFrameListener(@NonNull OnDidFinishRenderingFrameListener listener) {
- mapChangeReceiver.addOnDidFinishRenderingFrameListener(listener);
- }
-
- /**
- * Set a callback that's invoked when the map has finished rendering a frame.
- *
- * @param listener The callback that's invoked when the map has finished rendering a frame
- */
- public void removeOnDidFinishRenderingFrameListener(@NonNull OnDidFinishRenderingFrameListener listener) {
- mapChangeReceiver.removeOnDidFinishRenderingFrameListener(listener);
- }
-
- /**
- * Set a callback that's invoked when the map will start rendering.
- *
- * @param listener The callback that's invoked when the map will start rendering
- */
- public void addOnWillStartRenderingMapListener(@NonNull OnWillStartRenderingMapListener listener) {
- mapChangeReceiver.addOnWillStartRenderingMapListener(listener);
- }
-
- /**
- * Set a callback that's invoked when the map will start rendering.
- *
- * @param listener The callback that's invoked when the map will start rendering
- */
- public void removeOnWillStartRenderingMapListener(@NonNull OnWillStartRenderingMapListener listener) {
- mapChangeReceiver.removeOnWillStartRenderingMapListener(listener);
- }
-
- /**
- * Set a callback that's invoked when the map has finished rendering.
- *
- * @param listener The callback that's invoked when the map has finished rendering
- */
- public void addOnDidFinishRenderingMapListener(@NonNull OnDidFinishRenderingMapListener listener) {
- mapChangeReceiver.addOnDidFinishRenderingMapListener(listener);
- }
-
- /**
- * Remove a callback that's invoked when the map has finished rendering.
- *
- * @param listener The callback that's invoked when the map has has finished rendering.
- */
- public void removeOnDidFinishRenderingMapListener(OnDidFinishRenderingMapListener listener) {
- mapChangeReceiver.removeOnDidFinishRenderingMapListener(listener);
- }
-
- /**
- * Set a callback that's invoked when the map has entered the idle state.
- *
- * @param listener The callback that's invoked when the map has entered the idle state.
- */
- public void addOnDidBecomeIdleListener(@NonNull OnDidBecomeIdleListener listener) {
- mapChangeReceiver.addOnDidBecomeIdleListener(listener);
- }
-
- /**
- * Remove a callback that's invoked when the map has entered the idle state.
- *
- * @param listener The callback that's invoked when the map has entered the idle state.
- */
- public void removeOnDidBecomeIdleListener(@NonNull OnDidBecomeIdleListener listener) {
- mapChangeReceiver.removeOnDidBecomeIdleListener(listener);
- }
-
- /**
- * Set a callback that's invoked when the style has finished loading.
- *
- * @param listener The callback that's invoked when the style has finished loading
- */
- public void addOnDidFinishLoadingStyleListener(@NonNull OnDidFinishLoadingStyleListener listener) {
- mapChangeReceiver.addOnDidFinishLoadingStyleListener(listener);
- }
-
- /**
- * Set a callback that's invoked when the style has finished loading.
- *
- * @param listener The callback that's invoked when the style has finished loading
- */
- public void removeOnDidFinishLoadingStyleListener(@NonNull OnDidFinishLoadingStyleListener listener) {
- mapChangeReceiver.removeOnDidFinishLoadingStyleListener(listener);
- }
-
- /**
- * Set a callback that's invoked when a map source has changed.
- *
- * @param listener The callback that's invoked when the source has changed
- */
- public void addOnSourceChangedListener(@NonNull OnSourceChangedListener listener) {
- mapChangeReceiver.addOnSourceChangedListener(listener);
- }
-
- /**
- * Set a callback that's invoked when a map source has changed.
- *
- * @param listener The callback that's invoked when the source has changed
- */
- public void removeOnSourceChangedListener(@NonNull OnSourceChangedListener listener) {
- mapChangeReceiver.removeOnSourceChangedListener(listener);
- }
-
- /**
- * Set a callback that's invoked when the id of an icon is missing.
- *
- * @param listener The callback that's invoked when the id of an icon is missing
- */
- public void addOnStyleImageMissingListener(@NonNull OnStyleImageMissingListener listener) {
- mapChangeReceiver.addOnStyleImageMissingListener(listener);
- }
-
- /**
- * Set a callback that's invoked when a map source has changed.
- *
- * @param listener The callback that's invoked when the source has changed
- */
- public void removeOnStyleImageMissingListener(@NonNull OnStyleImageMissingListener listener) {
- mapChangeReceiver.removeOnStyleImageMissingListener(listener);
- }
-
- /**
- * Set a callback that's invoked when map needs to release unused image resources.
- * <p>
- * A callback will be called only for unused images that were provided by the client via
- * {@link OnStyleImageMissingListener#onStyleImageMissing(String)} listener interface.
- * </p>
- * <p>
- * By default, platform will remove unused images from the style. By adding listener, default
- * behavior can be overridden and client can control whether to release unused resources.
- * </p>
- *
- * @param listener The callback that's invoked when map needs to release unused image resources
- */
- public void addOnCanRemoveUnusedStyleImageListener(@NonNull OnCanRemoveUnusedStyleImageListener listener) {
- mapChangeReceiver.addOnCanRemoveUnusedStyleImageListener(listener);
- }
-
- /**
- * Removes a callback that's invoked when map needs to release unused image resources.
- * <p>
- * When all listeners are removed, platform will fallback to default behavior, which is to remove
- * unused images from the style.
- * </p>
- *
- * @param listener The callback that's invoked when map needs to release unused image resources
- */
- public void removeOnCanRemoveUnusedStyleImageListener(@NonNull OnCanRemoveUnusedStyleImageListener listener) {
- mapChangeReceiver.removeOnCanRemoveUnusedStyleImageListener(listener);
- }
-
- /**
- * Interface definition for a callback to be invoked when the camera will change.
- * <p>
- * {@link MapView#addOnCameraWillChangeListener(OnCameraWillChangeListener)}
- * </p>
- */
- public interface OnCameraWillChangeListener {
-
- /**
- * Called when the camera region will change.
- */
- void onCameraWillChange(boolean animated);
- }
-
- /**
- * Interface definition for a callback to be invoked when the camera is changing.
- * <p>
- * {@link MapView#addOnCameraIsChangingListener(OnCameraIsChangingListener)}
- * </p>
- */
- public interface OnCameraIsChangingListener {
- /**
- * Called when the camera is changing.
- */
- void onCameraIsChanging();
- }
-
- /**
- * Interface definition for a callback to be invoked when the map region did change.
- * <p>
- * {@link MapView#addOnCameraDidChangeListener(OnCameraDidChangeListener)}
- * </p>
- */
- public interface OnCameraDidChangeListener {
- /**
- * Called when the camera did change.
- */
- void onCameraDidChange(boolean animated);
- }
-
- /**
- * Interface definition for a callback to be invoked when the map will start loading.
- * <p>
- * {@link MapView#addOnWillStartLoadingMapListener(OnWillStartLoadingMapListener)}
- * </p>
- */
- public interface OnWillStartLoadingMapListener {
- /**
- * Called when the map will start loading.
- */
- void onWillStartLoadingMap();
- }
-
- /**
- * Interface definition for a callback to be invoked when the map finished loading.
- * <p>
- * {@link MapView#addOnDidFinishLoadingMapListener(OnDidFinishLoadingMapListener)}
- * </p>
- */
- public interface OnDidFinishLoadingMapListener {
- /**
- * Called when the map has finished loading.
- */
- void onDidFinishLoadingMap();
- }
-
- /**
- * Interface definition for a callback to be invoked when the map is changing.
- * <p>
- * {@link MapView#addOnDidFailLoadingMapListener(OnDidFailLoadingMapListener)}
- * </p>
- */
- public interface OnDidFailLoadingMapListener {
- /**
- * Called when the map failed to load.
- *
- * @param errorMessage The reason why the map failed to load
- */
- void onDidFailLoadingMap(String errorMessage);
- }
-
- /**
- * Interface definition for a callback to be invoked when the map will start rendering a frame.
- * <p>
- * {@link MapView#addOnWillStartRenderingFrameListener(OnWillStartRenderingFrameListener)}
- * </p>
- */
- public interface OnWillStartRenderingFrameListener {
- /**
- * Called when the map will start rendering a frame.
- */
- void onWillStartRenderingFrame();
- }
-
- /**
- * Interface definition for a callback to be invoked when the map finished rendering a frame.
- * <p>
- * {@link MapView#addOnDidFinishRenderingFrameListener(OnDidFinishRenderingFrameListener)}
- * </p>
- */
- public interface OnDidFinishRenderingFrameListener {
- /**
- * Called when the map has finished rendering a frame
- *
- * @param fully true if all frames have been rendered, false if partially rendered
- */
- void onDidFinishRenderingFrame(boolean fully);
- }
-
- /**
- * Interface definition for a callback to be invoked when the map will start rendering the map.
- * <p>
- * {@link MapView#addOnDidFailLoadingMapListener(OnDidFailLoadingMapListener)}
- * </p>
- */
- public interface OnWillStartRenderingMapListener {
- /**
- * Called when the map will start rendering.
- */
- void onWillStartRenderingMap();
- }
-
- /**
- * Interface definition for a callback to be invoked when the map is changing.
- * <p>
- * {@link MapView#addOnDidFinishRenderingMapListener(OnDidFinishRenderingMapListener)}
- * </p>
- */
- public interface OnDidFinishRenderingMapListener {
- /**
- * Called when the map has finished rendering.
- *
- * @param fully true if map is fully rendered, false if not fully rendered
- */
- void onDidFinishRenderingMap(boolean fully);
- }
-
- /**
- * Interface definition for a callback to be invoked when the map has entered the idle state.
- * <p>
- * Calling {@link MapboxMap#snapshot(MapboxMap.SnapshotReadyCallback)} from this callback
- * will result in recursive execution. Use {@link OnDidFinishRenderingFrameListener} instead.
- * </p>
- * <p>
- * {@link MapView#addOnDidBecomeIdleListener(OnDidBecomeIdleListener)}
- * </p>
- */
- public interface OnDidBecomeIdleListener {
- /**
- * Called when the map has entered the idle state.
- */
- void onDidBecomeIdle();
- }
-
- /**
- * Interface definition for a callback to be invoked when the map has loaded the style.
- * <p>
- * {@link MapView#addOnDidFailLoadingMapListener(OnDidFailLoadingMapListener)}
- * </p>
- */
- public interface OnDidFinishLoadingStyleListener {
- /**
- * Called when a style has finished loading.
- */
- void onDidFinishLoadingStyle();
- }
-
- /**
- * Interface definition for a callback to be invoked when a map source has changed.
- * <p>
- * {@link MapView#addOnDidFailLoadingMapListener(OnDidFailLoadingMapListener)}
- * </p>
- */
- public interface OnSourceChangedListener {
- /**
- * Called when a map source has changed.
- *
- * @param id the id of the source that has changed
- */
- void onSourceChangedListener(String id);
- }
-
- /**
- * Interface definition for a callback to be invoked with the id of a missing icon. The icon should be added
- * synchronously with {@link Style#addImage(String, Bitmap)} to be rendered on the current zoom level. When loading
- * icons asynchronously, you can load a placeholder image and replace it when you icon has loaded.
- * <p>
- * {@link MapView#addOnStyleImageMissingListener(OnStyleImageMissingListener)}
- * </p>
- */
- public interface OnStyleImageMissingListener {
- /**
- * Called when the map is missing an icon.The icon should be added synchronously with
- * {@link Style#addImage(String, Bitmap)} to be rendered on the current zoom level. When loading icons
- * asynchronously, you can load a placeholder image and replace it when you icon has loaded.
- *
- * @param id the id of the icon that is missing
- */
- void onStyleImageMissing(@NonNull String id);
- }
-
- /**
- * Interface definition for a callback to be invoked with an unused image identifier.
- * <p>
- * {@link MapView#addOnCanRemoveUnusedStyleImageListener(OnCanRemoveUnusedStyleImageListener)}
- * </p>
- */
- public interface OnCanRemoveUnusedStyleImageListener {
- /**
- * Called when the map needs to release unused image resources.
- *
- * @param id of an image that is not used by the map and can be removed from the style.
- * @return true if image can be removed, false otherwise.
- */
- boolean onCanRemoveUnusedStyleImage(@NonNull String id);
- }
-
- /**
- * Sets a callback object which will be triggered when the {@link MapboxMap} instance is ready to be used.
- *
- * @param callback The callback object that will be triggered when the map is ready to be used.
- */
- @UiThread
- public void getMapAsync(final @NonNull OnMapReadyCallback callback) {
- if (mapboxMap == null) {
- // Add callback to the list only if the style hasn't loaded, or the drawing surface isn't ready
- mapCallback.addOnMapReadyCallback(callback);
- } else {
- callback.onMapReady(mapboxMap);
- }
- }
-
- private boolean isGestureDetectorInitialized() {
- return mapGestureDetector != null;
- }
-
- @Nullable
- MapboxMap getMapboxMap() {
- return mapboxMap;
- }
-
- void setMapboxMap(MapboxMap mapboxMap) {
- this.mapboxMap = mapboxMap;
- }
-
- private class FocalPointInvalidator implements FocalPointChangeListener {
-
- private final List<FocalPointChangeListener> focalPointChangeListeners = new ArrayList<>();
-
- void addListener(FocalPointChangeListener focalPointChangeListener) {
- focalPointChangeListeners.add(focalPointChangeListener);
- }
-
- @Override
- public void onFocalPointChanged(PointF pointF) {
- mapGestureDetector.setFocalPoint(pointF);
- for (FocalPointChangeListener focalPointChangeListener : focalPointChangeListeners) {
- focalPointChangeListener.onFocalPointChanged(pointF);
- }
- }
- }
-
- /**
- * The initial render callback waits for rendering to happen before making the map visible for end-users.
- * We wait for the second DID_FINISH_RENDERING_FRAME map change event as the first will still show a black surface.
- */
- private class InitialRenderCallback implements OnDidFinishRenderingFrameListener {
-
- private int renderCount;
-
- InitialRenderCallback() {
- addOnDidFinishRenderingFrameListener(this);
- }
-
- @Override
- public void onDidFinishRenderingFrame(boolean fully) {
- if (mapboxMap != null && mapboxMap.getStyle() != null && mapboxMap.getStyle().isFullyLoaded()) {
- renderCount++;
- if (renderCount == 3) {
- MapView.this.setForeground(null);
- removeOnDidFinishRenderingFrameListener(this);
- }
- }
- }
-
- private void onDestroy() {
- removeOnDidFinishRenderingFrameListener(this);
- }
- }
-
- private class GesturesManagerInteractionListener implements MapboxMap.OnGesturesManagerInteractionListener {
-
- @Override
- public void onAddMapClickListener(MapboxMap.OnMapClickListener listener) {
- mapGestureDetector.addOnMapClickListener(listener);
- }
-
- @Override
- public void onRemoveMapClickListener(MapboxMap.OnMapClickListener listener) {
- mapGestureDetector.removeOnMapClickListener(listener);
- }
-
- @Override
- public void onAddMapLongClickListener(MapboxMap.OnMapLongClickListener listener) {
- mapGestureDetector.addOnMapLongClickListener(listener);
- }
-
- @Override
- public void onRemoveMapLongClickListener(MapboxMap.OnMapLongClickListener listener) {
- mapGestureDetector.removeOnMapLongClickListener(listener);
- }
-
- @Override
- public void onAddFlingListener(MapboxMap.OnFlingListener listener) {
- mapGestureDetector.addOnFlingListener(listener);
- }
-
- @Override
- public void onRemoveFlingListener(MapboxMap.OnFlingListener listener) {
- mapGestureDetector.removeOnFlingListener(listener);
- }
-
- @Override
- public void onAddMoveListener(MapboxMap.OnMoveListener listener) {
- mapGestureDetector.addOnMoveListener(listener);
- }
-
- @Override
- public void onRemoveMoveListener(MapboxMap.OnMoveListener listener) {
- mapGestureDetector.removeOnMoveListener(listener);
- }
-
- @Override
- public void onAddRotateListener(MapboxMap.OnRotateListener listener) {
- mapGestureDetector.addOnRotateListener(listener);
- }
-
- @Override
- public void onRemoveRotateListener(MapboxMap.OnRotateListener listener) {
- mapGestureDetector.removeOnRotateListener(listener);
- }
-
- @Override
- public void onAddScaleListener(MapboxMap.OnScaleListener listener) {
- mapGestureDetector.addOnScaleListener(listener);
- }
-
- @Override
- public void onRemoveScaleListener(MapboxMap.OnScaleListener listener) {
- mapGestureDetector.removeOnScaleListener(listener);
- }
-
- @Override
- public void onAddShoveListener(MapboxMap.OnShoveListener listener) {
- mapGestureDetector.addShoveListener(listener);
- }
-
- @Override
- public void onRemoveShoveListener(MapboxMap.OnShoveListener listener) {
- mapGestureDetector.removeShoveListener(listener);
- }
-
- @Override
- public AndroidGesturesManager getGesturesManager() {
- return mapGestureDetector.getGesturesManager();
- }
-
- @Override
- public void setGesturesManager(AndroidGesturesManager gesturesManager, boolean attachDefaultListeners,
- boolean setDefaultMutuallyExclusives) {
- mapGestureDetector.setGesturesManager(
- getContext(), gesturesManager, attachDefaultListeners, setDefaultMutuallyExclusives);
- }
-
- @Override
- public void cancelAllVelocityAnimations() {
- mapGestureDetector.cancelAnimators();
- }
- }
-
- private class MapCallback implements OnDidFinishLoadingStyleListener,
- OnDidFinishRenderingFrameListener, OnDidFinishLoadingMapListener,
- OnCameraIsChangingListener, OnCameraDidChangeListener, OnDidFailLoadingMapListener {
-
- private final List<OnMapReadyCallback> onMapReadyCallbackList = new ArrayList<>();
-
- MapCallback() {
- addOnDidFinishLoadingStyleListener(this);
- addOnDidFinishRenderingFrameListener(this);
- addOnDidFinishLoadingMapListener(this);
- addOnCameraIsChangingListener(this);
- addOnCameraDidChangeListener(this);
- addOnDidFailLoadingMapListener(this);
- }
-
- void initialised() {
- mapboxMap.onPreMapReady();
- onMapReady();
- mapboxMap.onPostMapReady();
- }
-
- /**
- * Notify listeners, clear when done
- */
- private void onMapReady() {
- if (onMapReadyCallbackList.size() > 0) {
- Iterator<OnMapReadyCallback> iterator = onMapReadyCallbackList.iterator();
- while (iterator.hasNext()) {
- OnMapReadyCallback callback = iterator.next();
- if (callback != null) {
- // null checking required for #13279
- callback.onMapReady(mapboxMap);
- }
- iterator.remove();
- }
- }
- }
-
- void addOnMapReadyCallback(OnMapReadyCallback callback) {
- onMapReadyCallbackList.add(callback);
- }
-
- void onDestroy() {
- onMapReadyCallbackList.clear();
- removeOnDidFinishLoadingStyleListener(this);
- removeOnDidFinishRenderingFrameListener(this);
- removeOnDidFinishLoadingMapListener(this);
- removeOnCameraIsChangingListener(this);
- removeOnCameraDidChangeListener(this);
- removeOnDidFailLoadingMapListener(this);
- }
-
- @Override
- public void onDidFinishLoadingStyle() {
- if (mapboxMap != null) {
- mapboxMap.onFinishLoadingStyle();
- }
- }
-
- @Override
- public void onDidFailLoadingMap(String errorMessage) {
- if (mapboxMap != null) {
- mapboxMap.onFailLoadingStyle();
- }
- }
-
- @Override
- public void onDidFinishRenderingFrame(boolean fully) {
- if (mapboxMap != null) {
- mapboxMap.onUpdateFullyRendered();
- }
- }
-
- @Override
- public void onDidFinishLoadingMap() {
- if (mapboxMap != null) {
- mapboxMap.onUpdateRegionChange();
- }
- }
-
- @Override
- public void onCameraIsChanging() {
- if (mapboxMap != null) {
- mapboxMap.onUpdateRegionChange();
- }
- }
-
- @Override
- public void onCameraDidChange(boolean animated) {
- if (mapboxMap != null) {
- mapboxMap.onUpdateRegionChange();
- }
- }
- }
-
- /**
- * Click event hook for providing a custom attribution dialog manager.
- */
- private static class AttributionClickListener implements OnClickListener {
-
- @NonNull
- private final AttributionDialogManager defaultDialogManager;
- private UiSettings uiSettings;
-
- private AttributionClickListener(@NonNull Context context, @NonNull MapboxMap mapboxMap) {
- this.defaultDialogManager = new AttributionDialogManager(context, mapboxMap);
- this.uiSettings = mapboxMap.getUiSettings();
- }
-
- @Override
- public void onClick(View v) {
- getDialogManager().onClick(v);
- }
-
- public void onStop() {
- getDialogManager().onStop();
- }
-
- private AttributionDialogManager getDialogManager() {
- AttributionDialogManager customDialogManager = uiSettings.getAttributionDialogManager();
- if (customDialogManager != null) {
- return uiSettings.getAttributionDialogManager();
- } else {
- return defaultDialogManager;
- }
- }
- }
-
- /**
- * Sets the strict mode that will throw the {@link com.mapbox.mapboxsdk.MapStrictModeException}
- * whenever the map would fail silently otherwise.
- *
- * @param strictModeEnabled true to enable the strict mode, false otherwise
- */
- public static void setMapStrictModeEnabled(boolean strictModeEnabled) {
- MapStrictMode.setStrictModeEnabled(strictModeEnabled);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
deleted file mode 100644
index 8f4cb9438c..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
+++ /dev/null
@@ -1,2425 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.PointF;
-import android.graphics.RectF;
-import android.os.Bundle;
-import android.support.annotation.FloatRange;
-import android.support.annotation.IntRange;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.annotation.Size;
-import android.support.annotation.UiThread;
-import android.text.TextUtils;
-import android.view.View;
-
-import com.mapbox.android.gestures.AndroidGesturesManager;
-import com.mapbox.android.gestures.MoveGestureDetector;
-import com.mapbox.android.gestures.RotateGestureDetector;
-import com.mapbox.android.gestures.ShoveGestureDetector;
-import com.mapbox.android.gestures.StandardScaleGestureDetector;
-import com.mapbox.geojson.Feature;
-import com.mapbox.geojson.Geometry;
-import com.mapbox.mapboxsdk.MapStrictMode;
-import com.mapbox.mapboxsdk.annotations.Annotation;
-import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
-import com.mapbox.mapboxsdk.annotations.Marker;
-import com.mapbox.mapboxsdk.annotations.MarkerOptions;
-import com.mapbox.mapboxsdk.annotations.Polygon;
-import com.mapbox.mapboxsdk.annotations.PolygonOptions;
-import com.mapbox.mapboxsdk.annotations.Polyline;
-import com.mapbox.mapboxsdk.annotations.PolylineOptions;
-import com.mapbox.mapboxsdk.camera.CameraPosition;
-import com.mapbox.mapboxsdk.camera.CameraUpdate;
-import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
-import com.mapbox.mapboxsdk.constants.MapboxConstants;
-import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.geometry.LatLngBounds;
-import com.mapbox.mapboxsdk.location.LocationComponent;
-import com.mapbox.mapboxsdk.log.Logger;
-import com.mapbox.mapboxsdk.offline.OfflineRegionDefinition;
-import com.mapbox.mapboxsdk.style.expressions.Expression;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * The general class to interact with in the Android Mapbox SDK. It exposes the entry point for all
- * methods related to the MapView. You cannot instantiate {@link MapboxMap} object directly, rather,
- * you must obtain one from the getMapAsync() method on a MapFragment or MapView that you have
- * added to your application.
- * <p>
- * Note: Similar to a View object, a MapboxMap should only be read and modified from the main thread.
- * </p>
- */
-@UiThread
-public final class MapboxMap {
-
- private static final String TAG = "Mbgl-MapboxMap";
-
- private final NativeMap nativeMapView;
- private final UiSettings uiSettings;
- private final Projection projection;
- private final Transform transform;
- private final CameraChangeDispatcher cameraChangeDispatcher;
- private final OnGesturesManagerInteractionListener onGesturesManagerInteractionListener;
- private final List<Style.OnStyleLoaded> awaitingStyleGetters = new ArrayList<>();
- private final List<OnDeveloperAnimationListener> developerAnimationStartedListeners;
-
- @Nullable
- private Style.OnStyleLoaded styleLoadedCallback;
-
- private LocationComponent locationComponent;
- private AnnotationManager annotationManager;
-
- @Nullable
- private MapboxMap.OnFpsChangedListener onFpsChangedListener;
-
- @Nullable
- private Style style;
-
- private boolean debugActive;
-
- MapboxMap(NativeMap map, Transform transform, UiSettings ui, Projection projection,
- OnGesturesManagerInteractionListener listener, CameraChangeDispatcher cameraChangeDispatcher,
- List<OnDeveloperAnimationListener> developerAnimationStartedListeners) {
- this.nativeMapView = map;
- this.uiSettings = ui;
- this.projection = projection;
- this.transform = transform;
- this.onGesturesManagerInteractionListener = listener;
- this.cameraChangeDispatcher = cameraChangeDispatcher;
- this.developerAnimationStartedListeners = developerAnimationStartedListeners;
- }
-
- void initialise(@NonNull Context context, @NonNull MapboxMapOptions options) {
- transform.initialise(this, options);
- uiSettings.initialise(context, options);
-
- // Map configuration
- setDebugActive(options.getDebugActive());
- setApiBaseUrl(options);
- setPrefetchesTiles(options);
- }
-
- /**
- * Get the Style of the map asynchronously.
- */
- public void getStyle(@NonNull Style.OnStyleLoaded onStyleLoaded) {
- if (style != null && style.isFullyLoaded()) {
- onStyleLoaded.onStyleLoaded(style);
- } else {
- awaitingStyleGetters.add(onStyleLoaded);
- }
- }
-
- /**
- * Get the Style of the map.
- * <p>
- * Returns null when style is being loaded.
- * </p>
- *
- * @return the style of the map
- */
- @Nullable
- public Style getStyle() {
- if (style == null || !style.isFullyLoaded()) {
- return null;
- } else {
- return style;
- }
- }
-
- /**
- * Called when the hosting Activity/Fragment onStart() method is called.
- */
- void onStart() {
- locationComponent.onStart();
- }
-
- /**
- * Called when the hosting Activity/Fragment onStop() method is called.
- */
- void onStop() {
- locationComponent.onStop();
- }
-
- /**
- * Called when the hosting Activity/Fragment is going to be destroyed and map state needs to be saved.
- *
- * @param outState the bundle to save the state to.
- */
- void onSaveInstanceState(@NonNull Bundle outState) {
- outState.putParcelable(MapboxConstants.STATE_CAMERA_POSITION, transform.getCameraPosition());
- outState.putBoolean(MapboxConstants.STATE_DEBUG_ACTIVE, isDebugActive());
- uiSettings.onSaveInstanceState(outState);
- }
-
- /**
- * Called when the hosting Activity/Fragment is recreated and map state needs to be restored.
- *
- * @param savedInstanceState the bundle containing the saved state
- */
- void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
- final CameraPosition cameraPosition = savedInstanceState.getParcelable(MapboxConstants.STATE_CAMERA_POSITION);
-
- uiSettings.onRestoreInstanceState(savedInstanceState);
-
- if (cameraPosition != null) {
- moveCamera(CameraUpdateFactory.newCameraPosition(
- new CameraPosition.Builder(cameraPosition).build())
- );
- }
-
- nativeMapView.setDebug(savedInstanceState.getBoolean(MapboxConstants.STATE_DEBUG_ACTIVE));
- }
-
- /**
- * Called when the hosting Activity/Fragment onDestroy()/onDestroyView() method is called.
- */
- void onDestroy() {
- locationComponent.onDestroy();
- if (style != null) {
- style.clear();
- }
- cameraChangeDispatcher.onDestroy();
- }
-
- /**
- * Called before the OnMapReadyCallback is invoked.
- */
- void onPreMapReady() {
- transform.invalidateCameraPosition();
- annotationManager.reloadMarkers();
- annotationManager.adjustTopOffsetPixels(this);
- }
-
- /**
- * Called when the OnMapReadyCallback has finished executing.
- * <p>
- * Invalidation of the camera position is required to update the added components in
- * OnMapReadyCallback with the correct transformation.
- * </p>
- */
- void onPostMapReady() {
- transform.invalidateCameraPosition();
- }
-
- /**
- * Called when the map finished loading a style.
- */
- void onFinishLoadingStyle() {
- notifyStyleLoaded();
- }
-
- /**
- * Called when the map failed loading a style.
- */
- void onFailLoadingStyle() {
- styleLoadedCallback = null;
- }
-
- /**
- * Called when the region is changing or has changed.
- */
- void onUpdateRegionChange() {
- annotationManager.update();
- }
-
- /**
- * Called when the map frame is fully rendered.
- */
- void onUpdateFullyRendered() {
- CameraPosition cameraPosition = transform.invalidateCameraPosition();
- if (cameraPosition != null) {
- uiSettings.update(cameraPosition);
- }
- }
-
- /**
- * Experimental feature. Do not use.
- */
- long getNativeMapPtr() {
- return nativeMapView.getNativePtr();
- }
-
- // Style
-
- /**
- * Sets tile pre-fetching zoom delta from MapboxOptions.
- *
- * @param options the options object
- */
- private void setPrefetchesTiles(@NonNull MapboxMapOptions options) {
- if (!options.getPrefetchesTiles()) {
- setPrefetchZoomDelta(0);
- } else {
- setPrefetchZoomDelta(options.getPrefetchZoomDelta());
- }
- }
-
- /**
- * Enable or disable tile pre-fetching. Pre-fetching makes sure that a low-resolution
- * tile is rendered as soon as possible at the expense of a little bandwidth.
- *
- * @param enable true to enable
- * @deprecated Use {@link #setPrefetchZoomDelta(int)} instead.
- */
- @Deprecated
- public void setPrefetchesTiles(boolean enable) {
- nativeMapView.setPrefetchTiles(enable);
- }
-
- /**
- * Check whether tile pre-fetching is enabled or not.
- *
- * @return true if enabled
- * @see MapboxMap#setPrefetchesTiles(boolean)
- * @deprecated Use {@link #getPrefetchZoomDelta()} instead.
- */
- @Deprecated
- public boolean getPrefetchesTiles() {
- return nativeMapView.getPrefetchTiles();
- }
-
- /**
- * Set the tile pre-fetching zoom delta. Pre-fetching makes sure that a low-resolution
- * tile at the (current_zoom_level - delta) is rendered as soon as possible at the
- * expense of a little bandwidth.
- * Note: This operation will override the MapboxMapOptions#setPrefetchesTiles(boolean)
- * Setting zoom delta to 0 will disable pre-fetching.
- * Default zoom delta is 4.
- *
- * @param delta zoom delta
- */
- public void setPrefetchZoomDelta(@IntRange(from = 0) int delta) {
- nativeMapView.setPrefetchZoomDelta(delta);
- }
-
- /**
- * Check current pre-fetching zoom delta.
- *
- * @return current zoom delta.
- * @see MapboxMap#setPrefetchZoomDelta(int)
- */
- @IntRange(from = 0)
- public int getPrefetchZoomDelta() {
- return nativeMapView.getPrefetchZoomDelta();
- }
-
- //
- // MinZoom
- //
-
- /**
- * <p>
- * Sets the minimum zoom level the map can be displayed at.
- * </p>
- *
- * @param minZoom The new minimum zoom level.
- */
- public void setMinZoomPreference(
- @FloatRange(from = MapboxConstants.MINIMUM_ZOOM, to = MapboxConstants.MAXIMUM_ZOOM) double minZoom) {
- transform.setMinZoom(minZoom);
- }
-
- /**
- * <p>
- * Gets the minimum zoom level the map can be displayed at.
- * </p>
- *
- * @return The minimum zoom level.
- */
- public double getMinZoomLevel() {
- return transform.getMinZoom();
- }
-
- //
- // MaxZoom
- //
-
- /**
- * <p>
- * Sets the maximum zoom level the map can be displayed at.
- * </p>
- * <p>
- * The default maximum zoomn level is 22. The upper bound for this value is 25.5.
- * </p>
- *
- * @param maxZoom The new maximum zoom level.
- */
- public void setMaxZoomPreference(@FloatRange(from = MapboxConstants.MINIMUM_ZOOM,
- to = MapboxConstants.MAXIMUM_ZOOM) double maxZoom) {
- transform.setMaxZoom(maxZoom);
- }
-
- /**
- * <p>
- * Gets the maximum zoom level the map can be displayed at.
- * </p>
- *
- * @return The maximum zoom level.
- */
- public double getMaxZoomLevel() {
- return transform.getMaxZoom();
- }
-
- //
- // UiSettings
- //
-
- /**
- * Gets the user interface settings for the map.
- *
- * @return the UiSettings associated with this map
- */
- @NonNull
- public UiSettings getUiSettings() {
- return uiSettings;
- }
-
- //
- // Projection
- //
-
- /**
- * Get the Projection object that you can use to convert between screen coordinates and latitude/longitude
- * coordinates.
- *
- * @return the Projection associated with this map
- */
- @NonNull
- public Projection getProjection() {
- return projection;
- }
-
- //
- // Camera API
- //
-
- /**
- * Cancels ongoing animations.
- * <p>
- * This invokes the {@link CancelableCallback} for ongoing camera updates.
- * </p>
- */
- public void cancelTransitions() {
- transform.cancelTransitions();
- }
-
- /**
- * Gets the current position of the camera.
- * The CameraPosition returned is a snapshot of the current position, and will not automatically update when the
- * camera moves.
- *
- * @return The current position of the Camera.
- */
- @NonNull
- public final CameraPosition getCameraPosition() {
- return transform.getCameraPosition();
- }
-
- /**
- * Repositions the camera according to the cameraPosition.
- * The move is instantaneous, and a subsequent getCameraPosition() will reflect the new position.
- * See CameraUpdateFactory for a set of updates.
- *
- * @param cameraPosition the camera position to set
- */
- public void setCameraPosition(@NonNull CameraPosition cameraPosition) {
- moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), null);
- }
-
- /**
- * Repositions the camera according to the instructions defined in the update.
- * The move is instantaneous, and a subsequent getCameraPosition() will reflect the new position.
- * See CameraUpdateFactory for a set of updates.
- *
- * @param update The change that should be applied to the camera.
- */
- public final void moveCamera(@NonNull CameraUpdate update) {
- moveCamera(update, null);
- }
-
- /**
- * Repositions the camera according to the instructions defined in the update.
- * The move is instantaneous, and a subsequent getCameraPosition() will reflect the new position.
- * See CameraUpdateFactory for a set of updates.
- *
- * @param update The change that should be applied to the camera
- * @param callback the callback to be invoked when an animation finishes or is canceled
- */
- public final void moveCamera(@NonNull final CameraUpdate update,
- @Nullable final MapboxMap.CancelableCallback callback) {
- notifyDeveloperAnimationListeners();
- transform.moveCamera(MapboxMap.this, update, callback);
- }
-
- /**
- * Gradually move the camera by the default duration, zoom will not be affected unless specified
- * within {@link CameraUpdate}. If {@link #getCameraPosition()} is called during the animation,
- * it will return the current location of the camera in flight.
- *
- * @param update The change that should be applied to the camera.
- * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates.
- */
- public final void easeCamera(@NonNull CameraUpdate update) {
- easeCamera(update, MapboxConstants.ANIMATION_DURATION);
- }
-
- /**
- * Gradually move the camera by the default duration, zoom will not be affected unless specified
- * within {@link CameraUpdate}. If {@link #getCameraPosition()} is called during the animation,
- * it will return the current location of the camera in flight.
- *
- * @param update The change that should be applied to the camera.
- * @param callback An optional callback to be notified from the main thread when the animation
- * stops. If the animation stops due to its natural completion, the callback
- * will be notified with onFinish(). If the animation stops due to interruption
- * by a later camera movement or a user gesture, onCancel() will be called.
- * Do not update or ease the camera from within onCancel().
- * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates.
- */
- public final void easeCamera(@NonNull CameraUpdate update, @Nullable final MapboxMap.CancelableCallback callback) {
- easeCamera(update, MapboxConstants.ANIMATION_DURATION, callback);
- }
-
- /**
- * Gradually move the camera by a specified duration in milliseconds, zoom will not be affected
- * unless specified within {@link CameraUpdate}. If {@link #getCameraPosition()} is called
- * during the animation, it will return the current location of the camera in flight.
- *
- * @param update The change that should be applied to the camera.
- * @param durationMs The duration of the animation in milliseconds. This must be strictly
- * positive, otherwise an IllegalArgumentException will be thrown.
- * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates.
- */
- public final void easeCamera(@NonNull CameraUpdate update, int durationMs) {
- easeCamera(update, durationMs, null);
- }
-
- /**
- * Gradually move the camera by a specified duration in milliseconds, zoom will not be affected
- * unless specified within {@link CameraUpdate}. A callback can be used to be notified when
- * easing the camera stops. If {@link #getCameraPosition()} is called during the animation, it
- * will return the current location of the camera in flight.
- * <p>
- * Note that this will cancel location tracking mode if enabled.
- * </p>
- *
- * @param update The change that should be applied to the camera.
- * @param durationMs The duration of the animation in milliseconds. This must be strictly
- * positive, otherwise an IllegalArgumentException will be thrown.
- * @param callback An optional callback to be notified from the main thread when the animation
- * stops. If the animation stops due to its natural completion, the callback
- * will be notified with onFinish(). If the animation stops due to interruption
- * by a later camera movement or a user gesture, onCancel() will be called.
- * Do not update or ease the camera from within onCancel().
- * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates.
- */
- public final void easeCamera(@NonNull CameraUpdate update, int durationMs,
- @Nullable final MapboxMap.CancelableCallback callback) {
- easeCamera(update, durationMs, true, callback);
- }
-
- /**
- * Gradually move the camera by a specified duration in milliseconds, zoom will not be affected
- * unless specified within {@link CameraUpdate}. A callback can be used to be notified when
- * easing the camera stops. If {@link #getCameraPosition()} is called during the animation, it
- * will return the current location of the camera in flight.
- * <p>
- * Note that this will cancel location tracking mode if enabled.
- * </p>
- *
- * @param update The change that should be applied to the camera.
- * @param durationMs The duration of the animation in milliseconds. This must be strictly
- * positive, otherwise an IllegalArgumentException will be thrown.
- * @param easingInterpolator True for easing interpolator, false for linear.
- */
- public final void easeCamera(@NonNull CameraUpdate update, int durationMs, boolean easingInterpolator) {
- easeCamera(update, durationMs, easingInterpolator, null);
- }
-
- /**
- * Gradually move the camera by a specified duration in milliseconds, zoom will not be affected
- * unless specified within {@link CameraUpdate}. A callback can be used to be notified when
- * easing the camera stops. If {@link #getCameraPosition()} is called during the animation, it
- * will return the current location of the camera in flight.
- *
- * @param update The change that should be applied to the camera.
- * @param durationMs The duration of the animation in milliseconds. This must be strictly
- * positive, otherwise an IllegalArgumentException will be thrown.
- * @param easingInterpolator True for easing interpolator, false for linear.
- * @param callback An optional callback to be notified from the main thread when the animation
- * stops. If the animation stops due to its natural completion, the callback
- * will be notified with onFinish(). If the animation stops due to interruption
- * by a later camera movement or a user gesture, onCancel() will be called.
- * Do not update or ease the camera from within onCancel().
- */
- public final void easeCamera(@NonNull final CameraUpdate update,
- final int durationMs,
- final boolean easingInterpolator,
- @Nullable final MapboxMap.CancelableCallback callback) {
- if (durationMs <= 0) {
- throw new IllegalArgumentException("Null duration passed into easeCamera");
- }
- notifyDeveloperAnimationListeners();
- transform.easeCamera(MapboxMap.this, update, durationMs, easingInterpolator, callback);
- }
-
- /**
- * Animate the camera to a new location defined within {@link CameraUpdate} using a transition
- * animation that evokes powered flight. The animation will last the default amount of time.
- * During the animation, a call to {@link #getCameraPosition()} returns an intermediate location
- * of the camera in flight.
- *
- * @param update The change that should be applied to the camera.
- * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates.
- */
- public final void animateCamera(@NonNull CameraUpdate update) {
- animateCamera(update, MapboxConstants.ANIMATION_DURATION, null);
- }
-
- /**
- * Animate the camera to a new location defined within {@link CameraUpdate} using a transition
- * animation that evokes powered flight. The animation will last the default amount of time. A
- * callback can be used to be notified when animating the camera stops. During the animation, a
- * call to {@link #getCameraPosition()} returns an intermediate location of the camera in flight.
- *
- * @param update The change that should be applied to the camera.
- * @param callback The callback to invoke from the main thread when the animation stops. If the
- * animation completes normally, onFinish() is called; otherwise, onCancel() is
- * called. Do not update or animate the camera from within onCancel().
- * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates.
- */
- public final void animateCamera(@NonNull CameraUpdate update, @Nullable MapboxMap.CancelableCallback callback) {
- animateCamera(update, MapboxConstants.ANIMATION_DURATION, callback);
- }
-
- /**
- * Animate the camera to a new location defined within {@link CameraUpdate} using a transition
- * animation that evokes powered flight. The animation will last a specified amount of time
- * given in milliseconds. During the animation, a call to {@link #getCameraPosition()} returns
- * an intermediate location of the camera in flight.
- *
- * @param update The change that should be applied to the camera.
- * @param durationMs The duration of the animation in milliseconds. This must be strictly
- * positive, otherwise an IllegalArgumentException will be thrown.
- * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates.
- */
- public final void animateCamera(@NonNull CameraUpdate update, int durationMs) {
- animateCamera(update, durationMs, null);
- }
-
- /**
- * Animate the camera to a new location defined within {@link CameraUpdate} using a transition
- * animation that evokes powered flight. The animation will last a specified amount of time
- * given in milliseconds. A callback can be used to be notified when animating the camera stops.
- * During the animation, a call to {@link #getCameraPosition()} returns an intermediate location
- * of the camera in flight.
- *
- * @param update The change that should be applied to the camera.
- * @param durationMs The duration of the animation in milliseconds. This must be strictly
- * positive, otherwise an IllegalArgumentException will be thrown.
- * @param callback An optional callback to be notified from the main thread when the animation
- * stops. If the animation stops due to its natural completion, the callback
- * will be notified with onFinish(). If the animation stops due to interruption
- * by a later camera movement or a user gesture, onCancel() will be called.
- * Do not update or animate the camera from within onCancel(). If a callback
- * isn't required, leave it as null.
- * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates.
- */
- public final void animateCamera(@NonNull final CameraUpdate update, final int durationMs,
- @Nullable final MapboxMap.CancelableCallback callback) {
- if (durationMs <= 0) {
- throw new IllegalArgumentException("Null duration passed into animateCamera");
- }
- notifyDeveloperAnimationListeners();
- transform.animateCamera(MapboxMap.this, update, durationMs, callback);
- }
-
- /**
- * Scrolls the camera over the map, shifting the center of view by the specified number of pixels in the x and y
- * directions.
- *
- * @param x Amount of pixels to scroll to in x direction
- * @param y Amount of pixels to scroll to in y direction
- */
- public void scrollBy(float x, float y) {
- scrollBy(x, y, 0);
- }
-
- /**
- * Scrolls the camera over the map, shifting the center of view by the specified number of pixels in the x and y
- * directions.
- *
- * @param x Amount of pixels to scroll to in x direction
- * @param y Amount of pixels to scroll to in y direction
- * @param duration Amount of time the scrolling should take
- */
- public void scrollBy(float x, float y, long duration) {
- notifyDeveloperAnimationListeners();
- nativeMapView.moveBy(x, y, duration);
- }
-
- //
- // Reset North
- //
-
- /**
- * Resets the map view to face north.
- */
- public void resetNorth() {
- notifyDeveloperAnimationListeners();
- transform.resetNorth();
- }
-
- /**
- * Transform the map bearing given a bearing, focal point coordinates, and a duration.
- *
- * @param bearing The bearing of the Map to be transformed to
- * @param focalX The x coordinate of the focal point
- * @param focalY The y coordinate of the focal point
- * @param duration The duration of the transformation
- */
- public void setFocalBearing(double bearing, float focalX, float focalY, long duration) {
- notifyDeveloperAnimationListeners();
- transform.setBearing(bearing, focalX, focalY, duration);
- }
-
- /**
- * Returns the measured height of the Map.
- *
- * @return the height of the map
- */
- public float getHeight() {
- return projection.getHeight();
- }
-
- /**
- * Returns the measured width of the Map.
- *
- * @return the width of the map
- */
- public float getWidth() {
- return projection.getWidth();
- }
-
- //
- // Offline
- //
-
- /**
- * Loads a new style from the specified offline region definition and moves the map camera to that region.
- *
- * @param definition the offline region definition
- * @see OfflineRegionDefinition
- */
- public void setOfflineRegionDefinition(@NonNull OfflineRegionDefinition definition) {
- setOfflineRegionDefinition(definition, null);
- }
-
- /**
- * Loads a new style from the specified offline region definition and moves the map camera to that region.
- *
- * @param definition the offline region definition
- * @param callback the callback to be invoked when the style has loaded
- * @see OfflineRegionDefinition
- */
- public void setOfflineRegionDefinition(@NonNull OfflineRegionDefinition definition,
- @Nullable Style.OnStyleLoaded callback) {
- double minZoom = definition.getMinZoom();
- double maxZoom = definition.getMaxZoom();
- CameraPosition cameraPosition = new CameraPosition.Builder()
- .target(definition.getBounds().getCenter())
- .zoom(minZoom)
- .build();
- moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
- setMinZoomPreference(minZoom);
- setMaxZoomPreference(maxZoom);
- setStyle(new Style.Builder().fromUri(definition.getStyleURL()), callback);
- }
-
- //
- // Debug
- //
-
- /**
- * Returns whether the map debug information is currently shown.
- *
- * @return If true, map debug information is currently shown.
- */
- public boolean isDebugActive() {
- return debugActive;
- }
-
- /**
- * <p>
- * Changes whether the map debug information is shown.
- * </p>
- * The default value is false.
- *
- * @param debugActive If true, map debug information is shown.
- */
- public void setDebugActive(boolean debugActive) {
- this.debugActive = debugActive;
- nativeMapView.setDebug(debugActive);
- }
-
- /**
- * <p>
- * Cycles through the map debug options.
- * </p>
- * The value of isDebugActive reflects whether there are
- * any map debug options enabled or disabled.
- *
- * @see #isDebugActive()
- */
- public void cycleDebugOptions() {
- nativeMapView.cycleDebugOptions();
- this.debugActive = nativeMapView.getDebug();
- }
-
- //
- // API endpoint config
- //
-
- private void setApiBaseUrl(@NonNull MapboxMapOptions options) {
- String apiBaseUrl = options.getApiBaseUrl();
- if (!TextUtils.isEmpty(apiBaseUrl)) {
- nativeMapView.setApiBaseUrl(apiBaseUrl);
- }
- }
-
- //
- // Styling
- //
-
- /**
- * Loads a new map style from the specified bundled style.
- * <p>
- * This method is asynchronous and will return before the style finishes loading.
- * If you wish to wait for the map to finish loading, listen to the {@link MapView.OnDidFinishLoadingStyleListener}
- * callback or use the {@link #setStyle(String, Style.OnStyleLoaded)} method instead.
- * </p>
- * If the style fails to load or an invalid style URL is set, the map view will become blank.
- * An error message will be logged in the Android logcat and {@link MapView.OnDidFailLoadingMapListener} callback
- * will be triggered.
- *
- * @param style The bundled style
- * @see Style
- */
- public void setStyle(@Style.StyleUrl String style) {
- this.setStyle(style, null);
- }
-
- /**
- * Loads a new map style from the specified bundled style.
- * <p>
- * If the style fails to load or an invalid style URL is set, the map view will become blank.
- * An error message will be logged in the Android logcat and {@link MapView.OnDidFailLoadingMapListener} callback
- * will be triggered.
- * </p>
- *
- * @param style The bundled style
- * @param callback The callback to be invoked when the style has loaded
- * @see Style
- */
- public void setStyle(@Style.StyleUrl String style, final Style.OnStyleLoaded callback) {
- this.setStyle(new Style.Builder().fromUri(style), callback);
- }
-
- /**
- * Loads a new map style from the specified builder.
- * <p>
- * If the builder fails to load, the map view will become blank. An error message will be logged in the Android logcat
- * and {@link MapView.OnDidFailLoadingMapListener} callback will be triggered. If you wish to wait for the map to
- * finish loading, listen to the {@link MapView.OnDidFinishLoadingStyleListener} callback or use the
- * {@link #setStyle(String, Style.OnStyleLoaded)} instead.
- * </p>
- *
- * @param builder The style builder
- * @see Style
- */
- public void setStyle(Style.Builder builder) {
- this.setStyle(builder, null);
- }
-
- /**
- * Loads a new map style from the specified builder.
- * <p>
- * If the builder fails to load, the map view will become blank. An error message will be logged in the Android logcat
- * and {@link MapView.OnDidFailLoadingMapListener} callback will be triggered.
- * </p>
- *
- * @param builder The style builder
- * @param callback The callback to be invoked when the style has loaded
- * @see Style
- */
- public void setStyle(Style.Builder builder, final Style.OnStyleLoaded callback) {
- styleLoadedCallback = callback;
- locationComponent.onStartLoadingMap();
- if (style != null) {
- style.clear();
- }
-
- style = builder.build(nativeMapView);
- if (!TextUtils.isEmpty(builder.getUri())) {
- nativeMapView.setStyleUri(builder.getUri());
- } else if (!TextUtils.isEmpty(builder.getJson())) {
- nativeMapView.setStyleJson(builder.getJson());
- } else {
- // user didn't provide a `from` component, load a blank style instead
- nativeMapView.setStyleJson(Style.EMPTY_JSON);
- }
- }
-
- void notifyStyleLoaded() {
- if (nativeMapView.isDestroyed()) {
- return;
- }
-
- if (style != null) {
- style.onDidFinishLoadingStyle();
- locationComponent.onFinishLoadingStyle();
-
- // notify the listener provided with the style setter
- if (styleLoadedCallback != null) {
- styleLoadedCallback.onStyleLoaded(style);
- }
-
- // notify style getters
- for (Style.OnStyleLoaded styleGetter : awaitingStyleGetters) {
- styleGetter.onStyleLoaded(style);
- }
- } else {
- MapStrictMode.strictModeViolation("No style to provide.");
- }
- styleLoadedCallback = null;
- awaitingStyleGetters.clear();
- }
-
- //
- // Annotations
- //
-
- /**
- * <p>
- * Adds a marker to this map.
- * </p>
- * The marker's icon is rendered on the map at the location {@code Marker.position}.
- * If {@code Marker.title} is defined, the map shows an info box with the marker's title and snippet.
- *
- * @param markerOptions A marker options object that defines how to render the marker
- * @return The {@code Marker} that was added to the map
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- @NonNull
- public Marker addMarker(@NonNull MarkerOptions markerOptions) {
- return annotationManager.addMarker(markerOptions, this);
- }
-
- /**
- * <p>
- * Adds a marker to this map.
- * </p>
- * The marker's icon is rendered on the map at the location {@code Marker.position}.
- * If {@code Marker.title} is defined, the map shows an info box with the marker's title and snippet.
- *
- * @param markerOptions A marker options object that defines how to render the marker
- * @return The {@code Marker} that was added to the map
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- @NonNull
- public Marker addMarker(@NonNull BaseMarkerOptions markerOptions) {
- return annotationManager.addMarker(markerOptions, this);
- }
-
- /**
- * <p>
- * Adds multiple markers to this map.
- * </p>
- * The marker's icon is rendered on the map at the location {@code Marker.position}.
- * If {@code Marker.title} is defined, the map shows an info box with the marker's title and snippet.
- *
- * @param markerOptionsList A list of marker options objects that defines how to render the markers
- * @return A list of the {@code Marker}s that were added to the map
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- @NonNull
- public List<Marker> addMarkers(@NonNull List<? extends
- BaseMarkerOptions> markerOptionsList) {
- return annotationManager.addMarkers(markerOptionsList, this);
- }
-
- /**
- * <p>
- * Updates a marker on this map. Does nothing if the marker isn't already added.
- * </p>
- *
- * @param updatedMarker An updated marker object
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public void updateMarker(@NonNull Marker updatedMarker) {
- annotationManager.updateMarker(updatedMarker, this);
- }
-
- /**
- * Adds a polyline to this map.
- *
- * @param polylineOptions A polyline options object that defines how to render the polyline
- * @return The {@code Polyine} that was added to the map
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- @NonNull
- public Polyline addPolyline(@NonNull PolylineOptions polylineOptions) {
- return annotationManager.addPolyline(polylineOptions, this);
- }
-
- /**
- * Adds multiple polylines to this map.
- *
- * @param polylineOptionsList A list of polyline options objects that defines how to render the polylines.
- * @return A list of the {@code Polyline}s that were added to the map.
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- @NonNull
- public List<Polyline> addPolylines(@NonNull List<PolylineOptions> polylineOptionsList) {
- return annotationManager.addPolylines(polylineOptionsList, this);
- }
-
- /**
- * Update a polyline on this map.
- *
- * @param polyline An updated polyline object.
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public void updatePolyline(@NonNull Polyline polyline) {
- annotationManager.updatePolyline(polyline);
- }
-
- /**
- * Adds a polygon to this map.
- *
- * @param polygonOptions A polygon options object that defines how to render the polygon.
- * @return The {@code Polygon} that was added to the map.
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- @NonNull
- public Polygon addPolygon(@NonNull PolygonOptions polygonOptions) {
- return annotationManager.addPolygon(polygonOptions, this);
- }
-
- /**
- * Adds multiple polygons to this map.
- *
- * @param polygonOptionsList A list of polygon options objects that defines how to render the polygons
- * @return A list of the {@code Polygon}s that were added to the map
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- @NonNull
- public List<Polygon> addPolygons(@NonNull List<PolygonOptions> polygonOptionsList) {
- return annotationManager.addPolygons(polygonOptionsList, this);
- }
-
- /**
- * Update a polygon on this map.
- *
- * @param polygon An updated polygon object
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public void updatePolygon(@NonNull Polygon polygon) {
- annotationManager.updatePolygon(polygon);
- }
-
- /**
- * <p>
- * Convenience method for removing a Marker from the map.
- * </p>
- * Calls removeAnnotation() internally.
- *
- * @param marker Marker to remove
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public void removeMarker(@NonNull Marker marker) {
- annotationManager.removeAnnotation(marker);
- }
-
- /**
- * <p>
- * Convenience method for removing a Polyline from the map.
- * </p>
- * Calls removeAnnotation() internally.
- *
- * @param polyline Polyline to remove
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public void removePolyline(@NonNull Polyline polyline) {
- annotationManager.removeAnnotation(polyline);
- }
-
- /**
- * <p>
- * Convenience method for removing a Polygon from the map.
- * </p>
- * Calls removeAnnotation() internally.
- *
- * @param polygon Polygon to remove
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public void removePolygon(@NonNull Polygon polygon) {
- annotationManager.removeAnnotation(polygon);
- }
-
- /**
- * Removes an annotation from the map.
- *
- * @param annotation The annotation object to remove.
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public void removeAnnotation(@NonNull Annotation annotation) {
- annotationManager.removeAnnotation(annotation);
- }
-
- /**
- * Removes an annotation from the map
- *
- * @param id The identifier associated to the annotation to be removed
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public void removeAnnotation(long id) {
- annotationManager.removeAnnotation(id);
- }
-
- /**
- * Removes multiple annotations from the map.
- *
- * @param annotationList A list of annotation objects to remove.
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public void removeAnnotations(@NonNull List<? extends Annotation> annotationList) {
- annotationManager.removeAnnotations(annotationList);
- }
-
- /**
- * Removes all annotations from the map.
- *
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public void removeAnnotations() {
- annotationManager.removeAnnotations();
- }
-
- /**
- * Removes all markers, polylines, polygons, overlays, etc from the map.
- *
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public void clear() {
- annotationManager.removeAnnotations();
- }
-
- /**
- * Return a annotation based on its id.
- *
- * @param id the id used to look up an annotation
- * @return An annotation with a matched id, null is returned if no match was found
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- @Nullable
- public Annotation getAnnotation(long id) {
- return annotationManager.getAnnotation(id);
- }
-
- /**
- * Returns a list of all the annotations on the map.
- *
- * @return A list of all the annotation objects. The returned object is a copy so modifying this
- * list will not update the map
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- @NonNull
- public List<Annotation> getAnnotations() {
- return annotationManager.getAnnotations();
- }
-
- /**
- * Returns a list of all the markers on the map.
- *
- * @return A list of all the markers objects. The returned object is a copy so modifying this
- * list will not update the map.
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- @NonNull
- public List<Marker> getMarkers() {
- return annotationManager.getMarkers();
- }
-
- /**
- * Returns a list of all the polygons on the map.
- *
- * @return A list of all the polygon objects. The returned object is a copy so modifying this
- * list will not update the map.
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- @NonNull
- public List<Polygon> getPolygons() {
- return annotationManager.getPolygons();
- }
-
- /**
- * Returns a list of all the polylines on the map.
- *
- * @return A list of all the polylines objects. The returned object is a copy so modifying this
- * list will not update the map.
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- @NonNull
- public List<Polyline> getPolylines() {
- return annotationManager.getPolylines();
- }
-
- /**
- * Sets a callback that's invoked when the user clicks on a marker.
- *
- * @param listener The callback that's invoked when the user clicks on a marker.
- * To unset the callback, use null.
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public void setOnMarkerClickListener(@Nullable OnMarkerClickListener listener) {
- annotationManager.setOnMarkerClickListener(listener);
- }
-
- /**
- * Sets a callback that's invoked when the user clicks on a polygon.
- *
- * @param listener The callback that's invoked when the user clicks on a polygon.
- * To unset the callback, use null.
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public void setOnPolygonClickListener(@Nullable OnPolygonClickListener listener) {
- annotationManager.setOnPolygonClickListener(listener);
- }
-
- /**
- * Sets a callback that's invoked when the user clicks on a polyline.
- *
- * @param listener The callback that's invoked when the user clicks on a polyline.
- * To unset the callback, use null.
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public void setOnPolylineClickListener(@Nullable OnPolylineClickListener listener) {
- annotationManager.setOnPolylineClickListener(listener);
- }
-
- /**
- * <p>
- * Selects a marker. The selected marker will have it's info window opened.
- * Any other open info windows will be closed unless isAllowConcurrentMultipleOpenInfoWindows()
- * is true.
- * </p>
- * Selecting an already selected marker will have no effect.
- *
- * @param marker The marker to select.
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public void selectMarker(@NonNull Marker marker) {
- if (marker == null) {
- Logger.w(TAG, "marker was null, so just returning");
- return;
- }
- annotationManager.selectMarker(marker);
- }
-
- /**
- * Deselects any currently selected marker. All markers will have it's info window closed.
- *
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public void deselectMarkers() {
- annotationManager.deselectMarkers();
- }
-
- /**
- * Deselects a currently selected marker. The selected marker will have it's info window closed.
- *
- * @param marker the marker to deselect
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public void deselectMarker(@NonNull Marker marker) {
- annotationManager.deselectMarker(marker);
- }
-
- /**
- * Gets the currently selected marker.
- *
- * @return The currently selected marker.
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- @NonNull
- public List<Marker> getSelectedMarkers() {
- return annotationManager.getSelectedMarkers();
- }
-
- //
- // InfoWindow
- //
-
- /**
- * <p>
- * Sets a custom renderer for the contents of info window.
- * </p>
- * When set your callback is invoked when an info window is about to be shown. By returning
- * a custom {@link View}, the default info window will be replaced.
- *
- * @param infoWindowAdapter The callback to be invoked when an info window will be shown.
- * To unset the callback, use null.
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public void setInfoWindowAdapter(@Nullable InfoWindowAdapter infoWindowAdapter) {
- annotationManager.getInfoWindowManager().setInfoWindowAdapter(infoWindowAdapter);
- }
-
- /**
- * Gets the callback to be invoked when an info window will be shown.
- *
- * @return The callback to be invoked when an info window will be shown.
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- @Nullable
- public InfoWindowAdapter getInfoWindowAdapter() {
- return annotationManager.getInfoWindowManager().getInfoWindowAdapter();
- }
-
- /**
- * Changes whether the map allows concurrent multiple infowindows to be shown.
- *
- * @param allow If true, map allows concurrent multiple infowindows to be shown.
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public void setAllowConcurrentMultipleOpenInfoWindows(boolean allow) {
- annotationManager.getInfoWindowManager().setAllowConcurrentMultipleOpenInfoWindows(allow);
- }
-
- /**
- * Returns whether the map allows concurrent multiple infowindows to be shown.
- *
- * @return If true, map allows concurrent multiple infowindows to be shown.
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public boolean isAllowConcurrentMultipleOpenInfoWindows() {
- return annotationManager.getInfoWindowManager().isAllowConcurrentMultipleOpenInfoWindows();
- }
-
- //
- // LatLngBounds
- //
-
- /**
- * Sets a LatLngBounds that constraints map transformations to this bounds.
- * <p>
- * Set to null to clear current bounds, newly set bounds will override previously set bounds.
- * </p>
- *
- * @param latLngBounds the bounds to constrain the map with
- */
- public void setLatLngBoundsForCameraTarget(@Nullable LatLngBounds latLngBounds) {
- nativeMapView.setLatLngBounds(latLngBounds);
- }
-
-
- /**
- * Get a camera position that fits a provided bounds and the current camera tilt and bearing.
- *
- * @param latLngBounds the bounds to set the map with
- * @return the camera position that fits the bounds
- */
- @Nullable
- public CameraPosition getCameraForLatLngBounds(@NonNull LatLngBounds latLngBounds) {
- // we use current camera tilt value to provide expected transformations as #11993
- return getCameraForLatLngBounds(latLngBounds, new int[] {0, 0, 0, 0});
- }
-
-
- /**
- * Get a camera position that fits a provided bounds and padding and the current camera tilt and bearing.
- *
- * @param latLngBounds the bounds to set the map with
- * @param padding the padding to apply to the bounds
- * @return the camera position that fits the bounds and padding
- */
- @Nullable
- public CameraPosition getCameraForLatLngBounds(@NonNull LatLngBounds latLngBounds,
- @NonNull @Size(value = 4) int[] padding) {
- // we use current camera tilt/bearing value to provide expected transformations as #11993
- return getCameraForLatLngBounds(latLngBounds, padding, transform.getRawBearing(), transform.getTilt());
- }
-
-
- /**
- * Get a camera position that fits a provided bounds, bearing and tilt.
- *
- * @param latLngBounds the bounds to set the map with
- * @param bearing the bearing to transform the camera position with
- * @param tilt to transform the camera position with
- * @return the camera position that fits the bounds and given bearing and tilt
- */
- @Nullable
- public CameraPosition getCameraForLatLngBounds(@NonNull LatLngBounds latLngBounds,
- @FloatRange(from = MapboxConstants.MINIMUM_DIRECTION,
- to = MapboxConstants.MAXIMUM_DIRECTION) double bearing,
- @FloatRange(from = MapboxConstants.MINIMUM_TILT,
- to = MapboxConstants.MAXIMUM_TILT) double tilt) {
- return getCameraForLatLngBounds(latLngBounds, new int[] {0, 0, 0, 0}, bearing, tilt);
- }
-
-
- /**
- * Get a camera position that fits a provided bounds, padding, bearing and tilt.
- *
- * @param latLngBounds the bounds to set the map with
- * @param padding the padding to apply to the bounds
- * @param bearing the bearing to transform the camera position with
- * @param tilt to transform the camera position with
- * @return the camera position that fits the bounds, bearing and tilt
- */
- @Nullable
- public CameraPosition getCameraForLatLngBounds(@NonNull LatLngBounds latLngBounds,
- @NonNull @Size(value = 4) int[] padding,
- @FloatRange(from = MapboxConstants.MINIMUM_DIRECTION,
- to = MapboxConstants.MAXIMUM_DIRECTION) double bearing,
- @FloatRange(from = MapboxConstants.MINIMUM_TILT,
- to = MapboxConstants.MAXIMUM_TILT) double tilt) {
- return nativeMapView.getCameraForLatLngBounds(latLngBounds, padding, bearing, tilt);
- }
-
- /**
- * Get a camera position that fits a provided shape.
- *
- * @param geometry the geometry to wraps the map with
- * @return the camera position that fits the geometry inside
- */
- @Nullable
- public CameraPosition getCameraForGeometry(@NonNull Geometry geometry) {
- // we use current camera tilt value to provide expected transformations as #11993
- return getCameraForGeometry(geometry, new int[] {0, 0, 0, 0});
- }
-
- /**
- * Get a camera position that fits a provided shape and padding.
- *
- * @param geometry the geometry to wraps the map with
- * @param padding the padding to apply to the bounds
- * @return the camera position that fits the geometry inside and padding
- */
- @Nullable
- public CameraPosition getCameraForGeometry(@NonNull Geometry geometry,
- @NonNull @Size(value = 4) int[] padding) {
- // we use current camera tilt/bearing value to provide expected transformations as #11993
- return getCameraForGeometry(geometry, padding, transform.getBearing(), transform.getTilt());
- }
-
- /**
- * Get a camera position that fits a provided shape with a given bearing and tilt.
- *
- * @param geometry the geometry to wraps the map with
- * @param bearing the bearing at which to compute the geometry's bounds
- * @param tilt the tilt at which to compute the geometry's bounds
- * @return the camera position that the geometry inside with bearing and tilt
- */
- @Nullable
- public CameraPosition getCameraForGeometry(@NonNull Geometry geometry,
- @FloatRange(from = MapboxConstants.MINIMUM_DIRECTION,
- to = MapboxConstants.MAXIMUM_DIRECTION) double bearing,
- @FloatRange(from = MapboxConstants.MINIMUM_TILT,
- to = MapboxConstants.MAXIMUM_TILT) double tilt) {
- return getCameraForGeometry(geometry, new int[] {0, 0, 0, 0}, bearing, tilt);
- }
-
- /**
- * Get a camera position that fits a provided shape with a given padding, bearing and tilt.
- *
- * @param geometry the geometry to wraps the map with
- * @param padding the padding to apply to the bounds
- * @param bearing the bearing at which to compute the geometry's bounds
- * @param tilt the tilt at which to compute the geometry's bounds
- * @return the camera position that fits the geometry inside with padding, bearing and tilt
- */
- @Nullable
- public CameraPosition getCameraForGeometry(@NonNull Geometry geometry,
- @NonNull @Size(value = 4) int[] padding,
- @FloatRange(from = MapboxConstants.MINIMUM_DIRECTION,
- to = MapboxConstants.MAXIMUM_DIRECTION) double bearing,
- @FloatRange(from = MapboxConstants.MINIMUM_TILT,
- to = MapboxConstants.MAXIMUM_TILT) double tilt) {
- return nativeMapView.getCameraForGeometry(geometry, padding, bearing, tilt);
- }
-
- //
- // Padding
- //
-
- /**
- * <p>
- * Sets the distance from the edges of the map view&#x27;s frame to the edges of the map
- * view&#x27s logical viewport.
- * </p>
- * <p>
- * When the value of this property is equal to {0,0,0,0}, viewport
- * properties such as &#x27;centerCoordinate&#x27; assume a viewport that matches the map
- * view&#x27;s frame. Otherwise, those properties are inset, excluding part of the
- * frame from the viewport. For instance, if the only the top edge is inset, the
- * map center is effectively shifted downward.
- * </p>
- * <p>
- * This method sets the padding "lazily".
- * This means that the <b>padding is going to be applied with the next camera transformation.</b>
- * To apply the padding immediately use {@link CameraPosition.Builder#padding(double, double, double, double)}
- * or {@link CameraUpdateFactory#paddingTo(double, double, double, double)}.
- * </p>
- *
- * @param left The left margin in pixels.
- * @param top The top margin in pixels.
- * @param right The right margin in pixels.
- * @param bottom The bottom margin in pixels.
- * @deprecated Use {@link CameraPosition.Builder#padding(double, double, double, double)}
- * or {@link CameraUpdateFactory#paddingTo(double, double, double, double)} instead.
- */
- @Deprecated
- public void setPadding(int left, int top, int right, int bottom) {
- // TODO padding should be passed as doubles
- projection.setContentPadding(new int[] {left, top, right, bottom});
- uiSettings.invalidate();
- }
-
- /**
- * Returns the current configured content padding on map view. This might return the currently visible padding
- * or the padding cached but not yet applied by {@link #setPadding(int, int, int, int)}.
- *
- * @return An array with length 4 in the LTRB order.
- * @deprecated Use {@link CameraPosition#padding} instead.
- */
- @Deprecated
- @NonNull
- public int[] getPadding() {
- // TODO this should return double[] (semver major change)
- return projection.getContentPadding();
- }
-
- //
- // Map events
- //
-
- /**
- * Adds a callback that is invoked when camera movement has ended.
- *
- * @param listener the listener to notify
- */
- public void addOnCameraIdleListener(@NonNull OnCameraIdleListener listener) {
- cameraChangeDispatcher.addOnCameraIdleListener(listener);
- }
-
- /**
- * Removes a callback that is invoked when camera movement has ended.
- *
- * @param listener the listener to remove
- */
- public void removeOnCameraIdleListener(@NonNull OnCameraIdleListener listener) {
- cameraChangeDispatcher.removeOnCameraIdleListener(listener);
- }
-
- /**
- * Adds a callback that is invoked when camera movement was cancelled.
- *
- * @param listener the listener to notify
- */
- public void addOnCameraMoveCancelListener(@NonNull OnCameraMoveCanceledListener listener) {
- cameraChangeDispatcher.addOnCameraMoveCancelListener(listener);
- }
-
- /**
- * Removes a callback that is invoked when camera movement was cancelled.
- *
- * @param listener the listener to remove
- */
- public void removeOnCameraMoveCancelListener(@NonNull OnCameraMoveCanceledListener listener) {
- cameraChangeDispatcher.removeOnCameraMoveCancelListener(listener);
- }
-
- /**
- * Adds a callback that is invoked when camera movement has started.
- *
- * @param listener the listener to notify
- */
- public void addOnCameraMoveStartedListener(@NonNull OnCameraMoveStartedListener listener) {
- cameraChangeDispatcher.addOnCameraMoveStartedListener(listener);
- }
-
- /**
- * Removes a callback that is invoked when camera movement has started.
- *
- * @param listener the listener to remove
- */
- public void removeOnCameraMoveStartedListener(@NonNull OnCameraMoveStartedListener listener) {
- cameraChangeDispatcher.removeOnCameraMoveStartedListener(listener);
- }
-
- /**
- * Adds a callback that is invoked when camera position changes.
- *
- * @param listener the listener to notify
- */
- public void addOnCameraMoveListener(@NonNull OnCameraMoveListener listener) {
- cameraChangeDispatcher.addOnCameraMoveListener(listener);
- }
-
- /**
- * Removes a callback that is invoked when camera position changes.
- *
- * @param listener the listener to remove
- */
- public void removeOnCameraMoveListener(@NonNull OnCameraMoveListener listener) {
- cameraChangeDispatcher.removeOnCameraMoveListener(listener);
- }
-
- /**
- * Sets a callback that's invoked on every frame rendered to the map view.
- *
- * @param listener The callback that's invoked on every frame rendered to the map view.
- * To unset the callback, use null.
- */
- public void setOnFpsChangedListener(@Nullable OnFpsChangedListener listener) {
- onFpsChangedListener = listener;
- nativeMapView.setOnFpsChangedListener(listener);
- }
-
- // used by MapView
- @Nullable
- OnFpsChangedListener getOnFpsChangedListener() {
- return onFpsChangedListener;
- }
-
- /**
- * Adds a callback that's invoked when the map is flinged.
- *
- * @param listener The callback that's invoked when the map is flinged.
- */
- public void addOnFlingListener(@NonNull OnFlingListener listener) {
- onGesturesManagerInteractionListener.onAddFlingListener(listener);
- }
-
- /**
- * Removes a callback that's invoked when the map is flinged.
- *
- * @param listener The callback that's invoked when the map is flinged.
- */
- public void removeOnFlingListener(@NonNull OnFlingListener listener) {
- onGesturesManagerInteractionListener.onRemoveFlingListener(listener);
- }
-
- /**
- * Adds a callback that's invoked when the map is moved.
- *
- * @param listener The callback that's invoked when the map is moved.
- */
- public void addOnMoveListener(@NonNull OnMoveListener listener) {
- onGesturesManagerInteractionListener.onAddMoveListener(listener);
- }
-
- /**
- * Removes a callback that's invoked when the map is moved.
- *
- * @param listener The callback that's invoked when the map is moved.
- */
- public void removeOnMoveListener(@NonNull OnMoveListener listener) {
- onGesturesManagerInteractionListener.onRemoveMoveListener(listener);
- }
-
- /**
- * Adds a callback that's invoked when the map is rotated.
- *
- * @param listener The callback that's invoked when the map is rotated.
- */
- public void addOnRotateListener(@NonNull OnRotateListener listener) {
- onGesturesManagerInteractionListener.onAddRotateListener(listener);
- }
-
- /**
- * Removes a callback that's invoked when the map is rotated.
- *
- * @param listener The callback that's invoked when the map is rotated.
- */
- public void removeOnRotateListener(@NonNull OnRotateListener listener) {
- onGesturesManagerInteractionListener.onRemoveRotateListener(listener);
- }
-
- /**
- * Adds a callback that's invoked when the map is scaled.
- *
- * @param listener The callback that's invoked when the map is scaled.
- */
- public void addOnScaleListener(@NonNull OnScaleListener listener) {
- onGesturesManagerInteractionListener.onAddScaleListener(listener);
- }
-
- /**
- * Removes a callback that's invoked when the map is scaled.
- *
- * @param listener The callback that's invoked when the map is scaled.
- */
- public void removeOnScaleListener(@NonNull OnScaleListener listener) {
- onGesturesManagerInteractionListener.onRemoveScaleListener(listener);
- }
-
- /**
- * Adds a callback that's invoked when the map is tilted.
- *
- * @param listener The callback that's invoked when the map is tilted.
- */
- public void addOnShoveListener(@NonNull OnShoveListener listener) {
- onGesturesManagerInteractionListener.onAddShoveListener(listener);
- }
-
- /**
- * Remove a callback that's invoked when the map is tilted.
- *
- * @param listener The callback that's invoked when the map is tilted.
- */
- public void removeOnShoveListener(@NonNull OnShoveListener listener) {
- onGesturesManagerInteractionListener.onRemoveShoveListener(listener);
- }
-
- /**
- * Sets a custom {@link AndroidGesturesManager} to handle {@link android.view.MotionEvent}s
- * registered by the {@link MapView}.
- *
- * @param androidGesturesManager Gestures manager that interprets gestures based on the motion events.
- * @param attachDefaultListeners If true, pre-defined listeners will be attach
- * to change map based on {@link AndroidGesturesManager} callbacks.
- * @param setDefaultMutuallyExclusives If true, pre-defined mutually exclusive gesture sets
- * will be added to the passed gestures manager.
- * @see <a href="https://github.com/mapbox/mapbox-gestures-android">mapbox-gestures-android library</a>
- */
- public void setGesturesManager(@NonNull AndroidGesturesManager androidGesturesManager, boolean attachDefaultListeners,
- boolean setDefaultMutuallyExclusives) {
- onGesturesManagerInteractionListener.setGesturesManager(
- androidGesturesManager, attachDefaultListeners, setDefaultMutuallyExclusives);
- }
-
- /**
- * Get current {@link AndroidGesturesManager} that handles {@link android.view.MotionEvent}s
- * registered by the {@link MapView}
- *
- * @return Current gestures manager.
- */
- @NonNull
- public AndroidGesturesManager getGesturesManager() {
- return onGesturesManagerInteractionListener.getGesturesManager();
- }
-
- /**
- * Interrupts any ongoing gesture velocity animations.
- */
- public void cancelAllVelocityAnimations() {
- onGesturesManagerInteractionListener.cancelAllVelocityAnimations();
- }
-
- /**
- * Adds a callback that's invoked when the user clicks on the map view.
- *
- * @param listener The callback that's invoked when the user clicks on the map view.
- */
- public void addOnMapClickListener(@NonNull OnMapClickListener listener) {
- onGesturesManagerInteractionListener.onAddMapClickListener(listener);
- }
-
- /**
- * Removes a callback that's invoked when the user clicks on the map view.
- *
- * @param listener The callback that's invoked when the user clicks on the map view.
- */
- public void removeOnMapClickListener(@NonNull OnMapClickListener listener) {
- onGesturesManagerInteractionListener.onRemoveMapClickListener(listener);
- }
-
- /**
- * Adds a callback that's invoked when the user long clicks on the map view.
- *
- * @param listener The callback that's invoked when the user long clicks on the map view.
- */
- public void addOnMapLongClickListener(@NonNull OnMapLongClickListener listener) {
- onGesturesManagerInteractionListener.onAddMapLongClickListener(listener);
- }
-
- /**
- * Removes a callback that's invoked when the user long clicks on the map view.
- *
- * @param listener The callback that's invoked when the user long clicks on the map view.
- */
- public void removeOnMapLongClickListener(@NonNull OnMapLongClickListener listener) {
- onGesturesManagerInteractionListener.onRemoveMapLongClickListener(listener);
- }
-
- /**
- * Sets a callback that's invoked when the user clicks on an info window.
- *
- * @param listener The callback that's invoked when the user clicks on an info window.
- * To unset the callback, use null.
- */
- public void setOnInfoWindowClickListener(@Nullable OnInfoWindowClickListener listener) {
- annotationManager.getInfoWindowManager().setOnInfoWindowClickListener(listener);
- }
-
- /**
- * Return the InfoWindow click listener
- *
- * @return Current active InfoWindow Click Listener
- */
- @Nullable
- public OnInfoWindowClickListener getOnInfoWindowClickListener() {
- return annotationManager.getInfoWindowManager().getOnInfoWindowClickListener();
- }
-
- /**
- * Sets a callback that's invoked when a marker's info window is long pressed.
- *
- * @param listener The callback that's invoked when a marker's info window is long pressed. To unset the callback,
- * use null.
- */
- public void setOnInfoWindowLongClickListener(@Nullable OnInfoWindowLongClickListener
- listener) {
- annotationManager.getInfoWindowManager().setOnInfoWindowLongClickListener(listener);
- }
-
- /**
- * Return the InfoWindow long click listener
- *
- * @return Current active InfoWindow long Click Listener
- */
- @Nullable
- public OnInfoWindowLongClickListener getOnInfoWindowLongClickListener() {
- return annotationManager.getInfoWindowManager().getOnInfoWindowLongClickListener();
- }
-
- /**
- * Set an callback to be invoked when an InfoWindow closes.
- *
- * @param listener callback invoked when an InfoWindow closes
- */
- public void setOnInfoWindowCloseListener(@Nullable OnInfoWindowCloseListener listener) {
- annotationManager.getInfoWindowManager().setOnInfoWindowCloseListener(listener);
- }
-
- /**
- * Return the InfoWindow close listener
- *
- * @return Current active InfoWindow Close Listener
- */
- @Nullable
- public OnInfoWindowCloseListener getOnInfoWindowCloseListener() {
- return annotationManager.getInfoWindowManager().getOnInfoWindowCloseListener();
- }
-
- //
- // Invalidate
- //
-
- /**
- * Takes a snapshot of the map.
- *
- * @param callback Callback method invoked when the snapshot is taken.
- */
- public void snapshot(@NonNull SnapshotReadyCallback callback) {
- nativeMapView.addSnapshotCallback(callback);
- }
-
- /**
- * Queries the map for rendered features.
- * <p>
- * Returns an empty list if either the map or underlying render surface has been destroyed.
- * </p>
- *
- * @param coordinates the point to query
- * @param layerIds optionally - only query these layers
- * @return the list of feature
- */
- @NonNull
- public List<Feature> queryRenderedFeatures(@NonNull PointF coordinates, @Nullable String... layerIds) {
- return nativeMapView.queryRenderedFeatures(coordinates, layerIds, null);
- }
-
- /**
- * Queries the map for rendered features
- * <p>
- * Returns an empty list if either the map or underlying render surface has been destroyed.
- * </p>
- *
- * @param coordinates the point to query
- * @param filter filters the returned features with an expression
- * @param layerIds optionally - only query these layers
- * @return the list of feature
- */
- @NonNull
- public List<Feature> queryRenderedFeatures(@NonNull PointF coordinates,
- @Nullable Expression filter,
- @Nullable String... layerIds) {
- return nativeMapView.queryRenderedFeatures(coordinates, layerIds, filter);
- }
-
- /**
- * Queries the map for rendered features
- * <p>
- * Returns an empty list if either the map or underlying render surface has been destroyed.
- * </p>
- *
- * @param coordinates the box to query
- * @param layerIds optionally - only query these layers
- * @return the list of feature
- */
- @NonNull
- public List<Feature> queryRenderedFeatures(@NonNull RectF coordinates, @Nullable String... layerIds) {
- return nativeMapView.queryRenderedFeatures(coordinates, layerIds, null);
- }
-
- /**
- * Queries the map for rendered features
- * <p>
- * Returns an empty list if either the map or underlying render surface has been destroyed.
- * </p>
- *
- * @param coordinates the box to query
- * @param filter filters the returned features with an expression
- * @param layerIds optionally - only query these layers
- * @return the list of feature
- */
- @NonNull
- public List<Feature> queryRenderedFeatures(@NonNull RectF coordinates,
- @Nullable Expression filter,
- @Nullable String... layerIds) {
- return nativeMapView.queryRenderedFeatures(coordinates, layerIds, filter);
- }
-
- //
- // LocationComponent
- //
-
- void injectLocationComponent(LocationComponent locationComponent) {
- this.locationComponent = locationComponent;
- }
-
- void injectAnnotationManager(AnnotationManager annotationManager) {
- this.annotationManager = annotationManager.bind(this);
- }
-
- /**
- * Returns the {@link LocationComponent} that can be used to display user's location on the map.
- * <p>
- * Use {@link LocationComponent#activateLocationComponent(Context, Style)} or any overload to activate the component,
- * then, enable it with {@link LocationComponent#setLocationComponentEnabled(boolean)}.
- * <p>
- * You can customize the location icon and more with {@link com.mapbox.mapboxsdk.location.LocationComponentOptions}.
- *
- * @return the Location Component
- */
- @NonNull
- public LocationComponent getLocationComponent() {
- return locationComponent;
- }
-
- //
- // Interfaces
- //
-
- /**
- * Interface definition for a callback to be invoked when the map is flinged.
- *
- * @see MapboxMap#addOnFlingListener(OnFlingListener)
- */
- public interface OnFlingListener {
- /**
- * Called when the map is flinged.
- */
- void onFling();
- }
-
- /**
- * Interface definition for a callback to be invoked when the map is moved.
- *
- * @see MapboxMap#addOnMoveListener(OnMoveListener)
- */
- public interface OnMoveListener {
- void onMoveBegin(@NonNull MoveGestureDetector detector);
-
- void onMove(@NonNull MoveGestureDetector detector);
-
- void onMoveEnd(@NonNull MoveGestureDetector detector);
- }
-
- /**
- * Interface definition for a callback to be invoked when the map is rotated.
- *
- * @see MapboxMap#addOnRotateListener(OnRotateListener)
- */
- public interface OnRotateListener {
- void onRotateBegin(@NonNull RotateGestureDetector detector);
-
- void onRotate(@NonNull RotateGestureDetector detector);
-
- void onRotateEnd(@NonNull RotateGestureDetector detector);
- }
-
- /**
- * Interface definition for a callback to be invoked when the map is scaled.
- *
- * @see MapboxMap#addOnScaleListener(OnScaleListener)
- */
- public interface OnScaleListener {
- void onScaleBegin(@NonNull StandardScaleGestureDetector detector);
-
- void onScale(@NonNull StandardScaleGestureDetector detector);
-
- void onScaleEnd(@NonNull StandardScaleGestureDetector detector);
- }
-
- /**
- * Interface definition for a callback to be invoked when the map is tilted.
- *
- * @see MapboxMap#addOnShoveListener(OnShoveListener)
- */
- public interface OnShoveListener {
- void onShoveBegin(@NonNull ShoveGestureDetector detector);
-
- void onShove(@NonNull ShoveGestureDetector detector);
-
- void onShoveEnd(@NonNull ShoveGestureDetector detector);
- }
-
- /**
- * Interface definition for a callback to be invoked for when the camera motion starts.
- */
- public interface OnCameraMoveStartedListener {
- int REASON_API_GESTURE = 1;
- int REASON_DEVELOPER_ANIMATION = 2;
- int REASON_API_ANIMATION = 3;
-
- /**
- * Called when the camera starts moving after it has been idle or when the reason for camera motion has changed.
- *
- * @param reason the reason for the camera change
- */
- void onCameraMoveStarted(int reason);
- }
-
- /**
- * Interface definition for a callback to be invoked for when the camera changes position.
- */
- public interface OnCameraMoveListener {
- /**
- * Called repeatedly as the camera continues to move after an onCameraMoveStarted call.
- * This may be called as often as once every frame and should not perform expensive operations.
- */
- void onCameraMove();
- }
-
- /**
- * Interface definition for a callback to be invoked for when the camera's motion has been stopped or when the camera
- * starts moving for a new reason.
- */
- public interface OnCameraMoveCanceledListener {
- /**
- * Called when the developer explicitly calls the cancelTransitions() method or if the reason for camera motion has
- * changed before the onCameraIdle had a chance to fire after the previous animation.
- * Do not update or animate the camera from within this method.
- */
- void onCameraMoveCanceled();
- }
-
- /**
- * Interface definition for a callback to be invoked for when camera movement has ended.
- */
- public interface OnCameraIdleListener {
- /**
- * Called when camera movement has ended.
- */
- void onCameraIdle();
- }
-
- /**
- * Interface definition for a callback to be invoked for when the compass is animating.
- */
- public interface OnCompassAnimationListener {
- /**
- * Called repeatedly as the compass continues to move after clicking on it.
- */
- void onCompassAnimation();
-
- /**
- * Called when compass animation has ended.
- */
- void onCompassAnimationFinished();
- }
-
- /**
- * Interface definition for a callback to be invoked when a frame is rendered to the map view.
- *
- * @see MapboxMap#setOnFpsChangedListener(OnFpsChangedListener)
- */
- public interface OnFpsChangedListener {
- /**
- * Called for every frame rendered to the map view.
- *
- * @param fps The average number of frames rendered over the last second.
- */
- void onFpsChanged(double fps);
- }
-
- /**
- * Interface definition for a callback to be invoked when a user registers an listener that is
- * related to touch and click events.
- */
- interface OnGesturesManagerInteractionListener {
-
- void onAddMapClickListener(OnMapClickListener listener);
-
- void onRemoveMapClickListener(OnMapClickListener listener);
-
- void onAddMapLongClickListener(OnMapLongClickListener listener);
-
- void onRemoveMapLongClickListener(OnMapLongClickListener listener);
-
- void onAddFlingListener(OnFlingListener listener);
-
- void onRemoveFlingListener(OnFlingListener listener);
-
- void onAddMoveListener(OnMoveListener listener);
-
- void onRemoveMoveListener(OnMoveListener listener);
-
- void onAddRotateListener(OnRotateListener listener);
-
- void onRemoveRotateListener(OnRotateListener listener);
-
- void onAddScaleListener(OnScaleListener listener);
-
- void onRemoveScaleListener(OnScaleListener listener);
-
- void onAddShoveListener(OnShoveListener listener);
-
- void onRemoveShoveListener(OnShoveListener listener);
-
- AndroidGesturesManager getGesturesManager();
-
- void setGesturesManager(AndroidGesturesManager gesturesManager, boolean attachDefaultListeners,
- boolean setDefaultMutuallyExclusives);
-
- void cancelAllVelocityAnimations();
- }
-
- /**
- * Interface definition for a callback to be invoked when the user clicks on the map view.
- *
- * @see MapboxMap#addOnMapClickListener(OnMapClickListener)
- */
- public interface OnMapClickListener {
- /**
- * Called when the user clicks on the map view.
- *
- * @param point The projected map coordinate the user clicked on.
- * @return True if this click should be consumed and not passed further to other listeners registered afterwards,
- * false otherwise.
- */
- boolean onMapClick(@NonNull LatLng point);
- }
-
- /**
- * Interface definition for a callback to be invoked when the user long clicks on the map view.
- *
- * @see MapboxMap#addOnMapLongClickListener(OnMapLongClickListener)
- */
- public interface OnMapLongClickListener {
- /**
- * Called when the user long clicks on the map view.
- *
- * @param point The projected map coordinate the user long clicked on.
- * @return True if this click should be consumed and not passed further to other listeners registered afterwards,
- * false otherwise.
- */
- boolean onMapLongClick(@NonNull LatLng point);
- }
-
- /**
- * Interface definition for a callback to be invoked when the user clicks on a marker.
- *
- * @see MapboxMap#setOnMarkerClickListener(OnMarkerClickListener)
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public interface OnMarkerClickListener {
- /**
- * Called when the user clicks on a marker.
- *
- * @param marker The marker the user clicked on.
- * @return If true the listener has consumed the event and the info window will not be shown.
- */
- boolean onMarkerClick(@NonNull Marker marker);
- }
-
- /**
- * Interface definition for a callback to be invoked when the user clicks on a polygon.
- *
- * @see MapboxMap#setOnPolygonClickListener(OnPolygonClickListener)
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public interface OnPolygonClickListener {
- /**
- * Called when the user clicks on a polygon.
- *
- * @param polygon The polygon the user clicked on.
- */
- void onPolygonClick(@NonNull Polygon polygon);
- }
-
- /**
- * Interface definition for a callback to be invoked when the user clicks on a polyline.
- *
- * @see MapboxMap#setOnPolylineClickListener(OnPolylineClickListener)
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public interface OnPolylineClickListener {
- /**
- * Called when the user clicks on a polyline.
- *
- * @param polyline The polyline the user clicked on.
- */
- void onPolylineClick(@NonNull Polyline polyline);
- }
-
- /**
- * Interface definition for a callback to be invoked when the user clicks on an info window.
- *
- * @see MapboxMap#setOnInfoWindowClickListener(OnInfoWindowClickListener)
- */
- public interface OnInfoWindowClickListener {
- /**
- * Called when the user clicks on an info window.
- *
- * @param marker The marker of the info window the user clicked on.
- * @return If true the listener has consumed the event and the info window will not be closed.
- */
- boolean onInfoWindowClick(@NonNull Marker marker);
- }
-
- /**
- * Interface definition for a callback to be invoked when the user long presses on a marker's info window.
- *
- * @see MapboxMap#setOnInfoWindowClickListener(OnInfoWindowClickListener)
- */
- public interface OnInfoWindowLongClickListener {
-
- /**
- * Called when the user makes a long-press gesture on the marker's info window.
- *
- * @param marker The marker were the info window is attached to
- */
- void onInfoWindowLongClick(@NonNull Marker marker);
- }
-
- /**
- * Interface definition for a callback to be invoked when a marker's info window is closed.
- *
- * @see MapboxMap#setOnInfoWindowCloseListener(OnInfoWindowCloseListener)
- */
- public interface OnInfoWindowCloseListener {
-
- /**
- * Called when the marker's info window is closed.
- *
- * @param marker The marker of the info window that was closed.
- */
- void onInfoWindowClose(@NonNull Marker marker);
- }
-
- /**
- * Interface definition for a callback to be invoked when an info window will be shown.
- *
- * @see MapboxMap#setInfoWindowAdapter(InfoWindowAdapter)
- * @deprecated As of 7.0.0,
- * use <a href="https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation">
- * Mapbox Annotation Plugin</a> instead
- */
- @Deprecated
- public interface InfoWindowAdapter {
- /**
- * Called when an info window will be shown as a result of a marker click.
- *
- * @param marker The marker the user clicked on.
- * @return View to be shown as a info window. If null is returned the default
- * info window will be shown.
- */
- @Nullable
- View getInfoWindow(@NonNull Marker marker);
- }
-
- /**
- * Interface definition for a callback to be invoked when a task is complete or cancelled.
- */
- public interface CancelableCallback {
- /**
- * Invoked when a task is cancelled.
- */
- void onCancel();
-
- /**
- * Invoked when a task is complete.
- */
- void onFinish();
- }
-
- /**
- * Interface definition for a callback to be invoked when the snapshot has been taken.
- */
- public interface SnapshotReadyCallback {
- /**
- * Invoked when the snapshot has been taken.
- *
- * @param snapshot the snapshot bitmap
- */
- void onSnapshotReady(@NonNull Bitmap snapshot);
- }
-
- /**
- * Internal use.
- */
- public interface OnDeveloperAnimationListener {
-
- /**
- * Notifies listener when a developer invoked animation is about to start.
- */
- void onDeveloperAnimationStarted();
- }
-
- //
- // Used for instrumentation testing
- //
- @NonNull
- Transform getTransform() {
- return transform;
- }
-
- private void notifyDeveloperAnimationListeners() {
- for (OnDeveloperAnimationListener listener : developerAnimationStartedListeners) {
- listener.onDeveloperAnimationStarted();
- }
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
deleted file mode 100644
index 8277568707..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java
+++ /dev/null
@@ -1,1283 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Bitmap;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.support.annotation.ColorInt;
-import android.support.annotation.IntRange;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.annotation.VisibleForTesting;
-import android.support.v4.content.res.ResourcesCompat;
-import android.text.TextUtils;
-import android.util.AttributeSet;
-import android.view.Gravity;
-
-import com.mapbox.mapboxsdk.R;
-import com.mapbox.mapboxsdk.camera.CameraPosition;
-import com.mapbox.mapboxsdk.constants.MapboxConstants;
-import com.mapbox.mapboxsdk.utils.BitmapUtils;
-import com.mapbox.mapboxsdk.utils.FontUtils;
-
-import java.util.Arrays;
-
-/**
- * Defines configuration MapboxMapMapOptions for a MapboxMap. These options can be used when adding a
- * map to your application programmatically (as opposed to via XML). If you are using a MapFragment,
- * you can pass these options in using the static factory method newInstance(MapboxMapOptions).
- * If you are using a MapView, you can pass these options in using the constructor
- * MapView(Context, MapboxMapOptions). If you add a map using XML, then you can apply these options
- * using custom XML tags.
- */
-public class MapboxMapOptions implements Parcelable {
-
- private static final int LIGHT_GRAY = 0xFFF0E9E1; // RGB(240, 233, 225))
- private static final float FOUR_DP = 4f;
- private static final float NINETY_TWO_DP = 92f;
- private static final int UNDEFINED_COLOR = -1;
-
- private CameraPosition cameraPosition;
-
- private boolean debugActive;
-
- private boolean compassEnabled = true;
- private boolean fadeCompassFacingNorth = true;
- private int compassGravity = Gravity.TOP | Gravity.END;
- private int[] compassMargins;
- private Drawable compassImage;
-
- private boolean logoEnabled = true;
- private int logoGravity = Gravity.BOTTOM | Gravity.START;
- private int[] logoMargins;
-
- @ColorInt
- private int attributionTintColor = UNDEFINED_COLOR;
- private boolean attributionEnabled = true;
- private int attributionGravity = Gravity.BOTTOM | Gravity.START;
- private int[] attributionMargins;
-
- private double minZoom = MapboxConstants.MINIMUM_ZOOM;
- private double maxZoom = MapboxConstants.MAXIMUM_ZOOM;
-
- private boolean rotateGesturesEnabled = true;
- private boolean scrollGesturesEnabled = true;
- private boolean tiltGesturesEnabled = true;
- private boolean zoomGesturesEnabled = true;
- private boolean doubleTapGesturesEnabled = true;
- private boolean quickZoomGesturesEnabled = true;
-
- private boolean prefetchesTiles = true;
- private int prefetchZoomDelta = 4;
- private boolean zMediaOverlay = false;
-
- private boolean localIdeographFontFamilyEnabled = true;
- private String localIdeographFontFamily;
- private String[] localIdeographFontFamilies;
-
- private String apiBaseUri;
-
- private boolean textureMode;
- private boolean translucentTextureSurface;
-
- @ColorInt
- private int foregroundLoadColor;
-
- private float pixelRatio;
-
- private boolean crossSourceCollisions = true;
-
- /**
- * Creates a new MapboxMapOptions object.
- *
- * @deprecated Use {@link #createFromAttributes(Context, AttributeSet)} instead.
- */
- @Deprecated
- public MapboxMapOptions() {
- }
-
- private MapboxMapOptions(Parcel in) {
- cameraPosition = in.readParcelable(CameraPosition.class.getClassLoader());
- debugActive = in.readByte() != 0;
-
- compassEnabled = in.readByte() != 0;
- compassGravity = in.readInt();
- compassMargins = in.createIntArray();
- fadeCompassFacingNorth = in.readByte() != 0;
-
- Bitmap compassBitmap = in.readParcelable(getClass().getClassLoader());
- if (compassBitmap != null) {
- compassImage = new BitmapDrawable(compassBitmap);
- }
-
- logoEnabled = in.readByte() != 0;
- logoGravity = in.readInt();
- logoMargins = in.createIntArray();
-
- attributionEnabled = in.readByte() != 0;
- attributionGravity = in.readInt();
- attributionMargins = in.createIntArray();
- attributionTintColor = in.readInt();
-
- minZoom = in.readDouble();
- maxZoom = in.readDouble();
-
- rotateGesturesEnabled = in.readByte() != 0;
- scrollGesturesEnabled = in.readByte() != 0;
- tiltGesturesEnabled = in.readByte() != 0;
- zoomGesturesEnabled = in.readByte() != 0;
- doubleTapGesturesEnabled = in.readByte() != 0;
- quickZoomGesturesEnabled = in.readByte() != 0;
-
- apiBaseUri = in.readString();
- textureMode = in.readByte() != 0;
- translucentTextureSurface = in.readByte() != 0;
- prefetchesTiles = in.readByte() != 0;
- prefetchZoomDelta = in.readInt();
- zMediaOverlay = in.readByte() != 0;
- localIdeographFontFamilyEnabled = in.readByte() != 0;
- localIdeographFontFamily = in.readString();
- localIdeographFontFamilies = in.createStringArray();
- pixelRatio = in.readFloat();
- foregroundLoadColor = in.readInt();
- crossSourceCollisions = in.readByte() != 0;
- }
-
- /**
- * Creates a default MapboxMapsOptions from a given context.
- *
- * @param context Context related to a map view.
- * @return the MapboxMapOptions created from attributes
- */
- @NonNull
- public static MapboxMapOptions createFromAttributes(@NonNull Context context) {
- return createFromAttributes(context, null);
- }
-
- /**
- * Creates a MapboxMapsOptions from the attribute set.
- *
- * @param context Context related to a map view.
- * @param attrs Attributeset containing configuration
- * @return the MapboxMapOptions created from attributes
- */
- @NonNull
- public static MapboxMapOptions createFromAttributes(@NonNull Context context, @Nullable AttributeSet attrs) {
- TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.mapbox_MapView, 0, 0);
- return createFromAttributes(new MapboxMapOptions(), context, typedArray);
- }
-
- @VisibleForTesting
- static MapboxMapOptions createFromAttributes(@NonNull MapboxMapOptions mapboxMapOptions,
- @NonNull Context context,
- @Nullable TypedArray typedArray) {
- float pxlRatio = context.getResources().getDisplayMetrics().density;
- try {
- mapboxMapOptions.camera(new CameraPosition.Builder(typedArray).build());
-
- // deprecated
- mapboxMapOptions.apiBaseUrl(typedArray.getString(R.styleable.mapbox_MapView_mapbox_apiBaseUrl));
-
- String baseUri = typedArray.getString(R.styleable.mapbox_MapView_mapbox_apiBaseUri);
- if (!TextUtils.isEmpty(baseUri)) {
- // override deprecated property if a value of the new type was provided
- mapboxMapOptions.apiBaseUri(baseUri);
- }
-
- mapboxMapOptions.zoomGesturesEnabled(
- typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_uiZoomGestures, true));
- mapboxMapOptions.scrollGesturesEnabled(
- typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_uiScrollGestures, true));
- mapboxMapOptions.rotateGesturesEnabled(
- typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_uiRotateGestures, true));
- mapboxMapOptions.tiltGesturesEnabled(
- typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_uiTiltGestures, true));
- mapboxMapOptions.doubleTapGesturesEnabled(
- typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_uiDoubleTapGestures, true));
- mapboxMapOptions.quickZoomGesturesEnabled(
- typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_uiQuickZoomGestures, true));
-
- mapboxMapOptions.maxZoomPreference(typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_cameraZoomMax,
- MapboxConstants.MAXIMUM_ZOOM));
- mapboxMapOptions.minZoomPreference(typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_cameraZoomMin,
- MapboxConstants.MINIMUM_ZOOM));
-
- mapboxMapOptions.compassEnabled(typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_uiCompass, true));
- mapboxMapOptions.compassGravity(typedArray.getInt(R.styleable.mapbox_MapView_mapbox_uiCompassGravity,
- Gravity.TOP | Gravity.END));
- mapboxMapOptions.compassMargins(new int[] {
- (int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiCompassMarginLeft,
- FOUR_DP * pxlRatio)),
- ((int) typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiCompassMarginTop,
- FOUR_DP * pxlRatio)),
- ((int) typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiCompassMarginRight,
- FOUR_DP * pxlRatio)),
- ((int) typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiCompassMarginBottom,
- FOUR_DP * pxlRatio))});
- mapboxMapOptions.compassFadesWhenFacingNorth(typedArray.getBoolean(
- R.styleable.mapbox_MapView_mapbox_uiCompassFadeFacingNorth, true));
- Drawable compassDrawable = typedArray.getDrawable(
- R.styleable.mapbox_MapView_mapbox_uiCompassDrawable);
- if (compassDrawable == null) {
- compassDrawable = ResourcesCompat.getDrawable(context.getResources(), R.drawable.mapbox_compass_icon, null);
- }
- mapboxMapOptions.compassImage(compassDrawable);
-
- mapboxMapOptions.logoEnabled(typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_uiLogo, true));
- mapboxMapOptions.logoGravity(typedArray.getInt(R.styleable.mapbox_MapView_mapbox_uiLogoGravity,
- Gravity.BOTTOM | Gravity.START));
- mapboxMapOptions.logoMargins(new int[] {
- (int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiLogoMarginLeft,
- FOUR_DP * pxlRatio)),
- (int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiLogoMarginTop,
- FOUR_DP * pxlRatio)),
- (int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiLogoMarginRight,
- FOUR_DP * pxlRatio)),
- (int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiLogoMarginBottom,
- FOUR_DP * pxlRatio))});
-
- mapboxMapOptions.attributionTintColor(typedArray.getColor(
- R.styleable.mapbox_MapView_mapbox_uiAttributionTintColor, UNDEFINED_COLOR));
- mapboxMapOptions.attributionEnabled(typedArray.getBoolean(
- R.styleable.mapbox_MapView_mapbox_uiAttribution, true));
- mapboxMapOptions.attributionGravity(typedArray.getInt(
- R.styleable.mapbox_MapView_mapbox_uiAttributionGravity, Gravity.BOTTOM | Gravity.START));
- mapboxMapOptions.attributionMargins(new int[] {
- (int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiAttributionMarginLeft,
- NINETY_TWO_DP * pxlRatio)),
- (int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiAttributionMarginTop,
- FOUR_DP * pxlRatio)),
- (int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiAttributionMarginRight,
- FOUR_DP * pxlRatio)),
- (int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiAttributionMarginBottom,
- FOUR_DP * pxlRatio))});
- mapboxMapOptions.textureMode(
- typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_renderTextureMode, false));
- mapboxMapOptions.translucentTextureSurface(
- typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_renderTextureTranslucentSurface, false));
- mapboxMapOptions.setPrefetchesTiles(
- typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_enableTilePrefetch, true));
- mapboxMapOptions.setPrefetchZoomDelta(
- typedArray.getInt(R.styleable.mapbox_MapView_mapbox_prefetchZoomDelta, 4));
- mapboxMapOptions.renderSurfaceOnTop(
- typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_enableZMediaOverlay, false));
-
- mapboxMapOptions.localIdeographFontFamilyEnabled =
- typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_localIdeographEnabled, true);
-
- int localIdeographFontFamiliesResId =
- typedArray.getResourceId(R.styleable.mapbox_MapView_mapbox_localIdeographFontFamilies, 0);
- if (localIdeographFontFamiliesResId != 0) {
- String[] localIdeographFontFamilies =
- context.getResources().getStringArray(localIdeographFontFamiliesResId);
- mapboxMapOptions.localIdeographFontFamily(localIdeographFontFamilies);
- } else {
- // did user provide xml font string?
- String localIdeographFontFamily =
- typedArray.getString(R.styleable.mapbox_MapView_mapbox_localIdeographFontFamily);
- if (localIdeographFontFamily == null) {
- localIdeographFontFamily = MapboxConstants.DEFAULT_FONT;
- }
- mapboxMapOptions.localIdeographFontFamily(localIdeographFontFamily);
- }
-
- mapboxMapOptions.pixelRatio(
- typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_pixelRatio, 0));
- mapboxMapOptions.foregroundLoadColor(
- typedArray.getInt(R.styleable.mapbox_MapView_mapbox_foregroundLoadColor, LIGHT_GRAY)
- );
- mapboxMapOptions.crossSourceCollisions(
- typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_cross_source_collisions, true)
- );
- } finally {
- typedArray.recycle();
- }
- return mapboxMapOptions;
- }
-
- /**
- * Specifies the URL used for API endpoint.
- *
- * @param apiBaseUrl The base of our API endpoint
- * @return This
- * @deprecated use {@link #apiBaseUri} instead
- */
- @Deprecated
- @NonNull
- public MapboxMapOptions apiBaseUrl(String apiBaseUrl) {
- this.apiBaseUri = apiBaseUrl;
- return this;
- }
-
- /**
- * Specifies the URI used for API endpoint.
- *
- * @param apiBaseUri The base of our API endpoint
- * @return This
- */
- @NonNull
- public MapboxMapOptions apiBaseUri(String apiBaseUri) {
- this.apiBaseUri = apiBaseUri;
- return this;
- }
-
- /**
- * Specifies a the initial camera position for the map view.
- *
- * @param cameraPosition Inital camera position
- * @return This
- */
- @NonNull
- public MapboxMapOptions camera(CameraPosition cameraPosition) {
- this.cameraPosition = cameraPosition;
- return this;
- }
-
- /**
- * Specifies the used debug type for a map view.
- *
- * @param enabled True is debug is enabled
- * @return This
- */
- @NonNull
- public MapboxMapOptions debugActive(boolean enabled) {
- debugActive = enabled;
- return this;
- }
-
- /**
- * Specifies the used minimum zoom level for a map view.
- *
- * @param minZoom Zoom level to be used
- * @return This
- */
- @NonNull
- public MapboxMapOptions minZoomPreference(double minZoom) {
- this.minZoom = minZoom;
- return this;
- }
-
- /**
- * Specifies the used maximum zoom level for a map view.
- *
- * @param maxZoom Zoom level to be used
- * @return This
- */
- @NonNull
- public MapboxMapOptions maxZoomPreference(double maxZoom) {
- this.maxZoom = maxZoom;
- return this;
- }
-
- /**
- * Specifies the visibility state of a mapbox_compass_icon for a map view.
- *
- * @param enabled True and mapbox_compass_icon is shown
- * @return This
- */
- @NonNull
- public MapboxMapOptions compassEnabled(boolean enabled) {
- compassEnabled = enabled;
- return this;
- }
-
- /**
- * Specifies the gravity state of mapbox_compass_icon for a map view.
- *
- * @param gravity Android SDK Gravity.
- * @return This
- */
- @NonNull
- public MapboxMapOptions compassGravity(int gravity) {
- compassGravity = gravity;
- return this;
- }
-
- /**
- * Specifies the margin state of mapbox_compass_icon for a map view
- *
- * @param margins 4 long array for LTRB margins
- * @return This
- */
- @NonNull
- public MapboxMapOptions compassMargins(int[] margins) {
- compassMargins = margins;
- return this;
- }
-
- /**
- * Specifies if the mapbox_compass_icon fades to invisible when facing north.
- * <p>
- * By default this value is true.
- * </p>
- *
- * @param compassFadeWhenFacingNorth true is mapbox_compass_icon fades to invisble
- * @return This
- */
- @NonNull
- public MapboxMapOptions compassFadesWhenFacingNorth(boolean compassFadeWhenFacingNorth) {
- this.fadeCompassFacingNorth = compassFadeWhenFacingNorth;
- return this;
- }
-
- /**
- * Specifies the image of the CompassView.
- * <p>
- * By default this value is R.drawable.mapbox_compass_icon.
- * </p>
- *
- * @param compass the drawable to show as image compass
- * @return This
- */
- @NonNull
- public MapboxMapOptions compassImage(Drawable compass) {
- this.compassImage = compass;
- return this;
- }
-
- /**
- * Specifies the visibility state of a logo for a map view.
- *
- * @param enabled True and logo is shown
- * @return This
- */
- @NonNull
- public MapboxMapOptions logoEnabled(boolean enabled) {
- logoEnabled = enabled;
- return this;
- }
-
- /**
- * Specifies the gravity state of logo for a map view.
- *
- * @param gravity Android SDK Gravity.
- * @return This
- */
- @NonNull
- public MapboxMapOptions logoGravity(int gravity) {
- logoGravity = gravity;
- return this;
- }
-
- /**
- * Specifies the margin state of logo for a map view
- *
- * @param margins 4 long array for LTRB margins
- * @return This
- */
- @NonNull
- public MapboxMapOptions logoMargins(int[] margins) {
- logoMargins = margins;
- return this;
- }
-
- /**
- * Specifies the visibility state of a attribution for a map view.
- *
- * @param enabled True and attribution is shown
- * @return This
- */
- @NonNull
- public MapboxMapOptions attributionEnabled(boolean enabled) {
- attributionEnabled = enabled;
- return this;
- }
-
- /**
- * Specifies the gravity state of attribution for a map view.
- *
- * @param gravity Android SDK Gravity.
- * @return This
- */
- @NonNull
- public MapboxMapOptions attributionGravity(int gravity) {
- attributionGravity = gravity;
- return this;
- }
-
- /**
- * Specifies the margin state of attribution for a map view
- *
- * @param margins 4 long array for LTRB margins
- * @return This
- */
- @NonNull
- public MapboxMapOptions attributionMargins(int[] margins) {
- attributionMargins = margins;
- return this;
- }
-
- /**
- * Specifies the tint color of the attribution for a map view
- *
- * @param color integer resembling a color
- * @return This
- */
- @NonNull
- public MapboxMapOptions attributionTintColor(@ColorInt int color) {
- attributionTintColor = color;
- return this;
- }
-
- /**
- * Specifies if the rotate gesture is enabled for a map view.
- *
- * @param enabled True and gesture will be enabled
- * @return This
- */
- @NonNull
- public MapboxMapOptions rotateGesturesEnabled(boolean enabled) {
- rotateGesturesEnabled = enabled;
- return this;
- }
-
- /**
- * Specifies if the scroll gesture is enabled for a map view.
- *
- * @param enabled True and gesture will be enabled
- * @return This
- */
- @NonNull
- public MapboxMapOptions scrollGesturesEnabled(boolean enabled) {
- scrollGesturesEnabled = enabled;
- return this;
- }
-
- /**
- * Specifies if the tilt gesture is enabled for a map view.
- *
- * @param enabled True and gesture will be enabled
- * @return This
- */
- @NonNull
- public MapboxMapOptions tiltGesturesEnabled(boolean enabled) {
- tiltGesturesEnabled = enabled;
- return this;
- }
-
- /**
- * Specifies if the zoom gesture is enabled for a map view.
- *
- * @param enabled True and gesture will be enabled
- * @return This
- */
- @NonNull
- public MapboxMapOptions zoomGesturesEnabled(boolean enabled) {
- zoomGesturesEnabled = enabled;
- return this;
- }
-
- /**
- * Specifies if the double tap gesture is enabled for a map view.
- *
- * @param enabled True and gesture will be enabled
- * @return This
- */
- @NonNull
- public MapboxMapOptions doubleTapGesturesEnabled(boolean enabled) {
- doubleTapGesturesEnabled = enabled;
- return this;
- }
-
- /**
- * Specifies whether the user may zoom the map by tapping twice, holding and moving the pointer up and down.
- *
- * @param enabled True and gesture will be enabled
- * @return This
- */
- @NonNull
- public MapboxMapOptions quickZoomGesturesEnabled(boolean enabled) {
- quickZoomGesturesEnabled = enabled;
- return this;
- }
-
- /**
- * Enable {@link android.view.TextureView} as rendered surface.
- * <p>
- * Since the 5.2.0 release we replaced our TextureView with an {@link android.opengl.GLSurfaceView}
- * implementation. Enabling this option will use the {@link android.view.TextureView} instead.
- * {@link android.view.TextureView} can be useful in situations where you need to animate, scale
- * or transform the view. This comes at a siginficant performance penalty and should not be considered
- * unless absolutely needed.
- * </p>
- *
- * @param textureMode True to enable texture mode
- * @return This
- */
- @NonNull
- public MapboxMapOptions textureMode(boolean textureMode) {
- this.textureMode = textureMode;
- return this;
- }
-
- @NonNull
- public MapboxMapOptions translucentTextureSurface(boolean translucentTextureSurface) {
- this.translucentTextureSurface = translucentTextureSurface;
- return this;
- }
-
- /**
- * Set the MapView foreground color that is used when the map surface is being created.
- *
- * @param loadColor the color to show during map creation
- * @return This
- */
- @NonNull
- public MapboxMapOptions foregroundLoadColor(@ColorInt int loadColor) {
- this.foregroundLoadColor = loadColor;
- return this;
- }
-
- /**
- * Enable tile pre-fetching. Loads tiles at a lower zoom-level to pre-render
- * a low resolution preview while more detailed tiles are loaded.
- * Enabled by default
- *
- * @param enable true to enable
- * @return This
- * @deprecated Use {@link #setPrefetchZoomDelta(int)} instead.
- */
- @Deprecated
- @NonNull
- public MapboxMapOptions setPrefetchesTiles(boolean enable) {
- this.prefetchesTiles = enable;
- return this;
- }
-
- /**
- * Set the tile pre-fetching zoom delta. Pre-fetching makes sure that a low-resolution
- * tile at the (current_zoom_level - delta) is rendered as soon as possible at the
- * expense of a little bandwidth.
- * Note: This operation will override the MapboxMapOptions#setPrefetchesTiles(boolean)
- * Setting zoom delta to 0 will disable pre-fetching.
- * Default zoom delta is 4.
- *
- * @param delta zoom delta
- * @return This
- */
- @NonNull
- public MapboxMapOptions setPrefetchZoomDelta(@IntRange(from = 0) int delta) {
- this.prefetchZoomDelta = delta;
- return this;
- }
-
- /**
- * Enable cross-source symbol collision detection, defaults to true.
- * <p>
- * If set to false, symbol layers will only run collision detection against
- * other symbol layers that are part of the same source.
- * </p>
- *
- * @param crossSourceCollisions true to enable, false to disable
- * @return This
- */
- @NonNull
- public MapboxMapOptions crossSourceCollisions(boolean crossSourceCollisions) {
- this.crossSourceCollisions = crossSourceCollisions;
- return this;
- }
-
- /**
- * Enable local ideograph font family, defaults to true.
- *
- * @param enabled true to enable, false to disable
- * @return This
- */
- @NonNull
- public MapboxMapOptions localIdeographFontFamilyEnabled(boolean enabled) {
- this.localIdeographFontFamilyEnabled = enabled;
- return this;
- }
-
- /**
- * Set the font family for generating glyphs locally for ideographs in the &#x27;CJK Unified Ideographs&#x27;
- * and &#x27;Hangul Syllables&#x27; ranges.
- * <p>
- * The font family argument is passed to {@link android.graphics.Typeface#create(String, int)}.
- * Default system fonts are defined in &#x27;/system/etc/fonts.xml&#x27;
- * Default font for local ideograph font family is {@link MapboxConstants#DEFAULT_FONT}.
- *
- * @param fontFamily font family for local ideograph generation.
- * @return This
- */
- @NonNull
- public MapboxMapOptions localIdeographFontFamily(String fontFamily) {
- this.localIdeographFontFamily = FontUtils.extractValidFont(fontFamily);
- return this;
- }
-
- /**
- * Set a font family from range of font families for generating glyphs locally for ideographs in the
- * &#x27;CJK Unified Ideographs&#x27; and &#x27;Hangul Syllables&#x27; ranges. The first matching font
- * will be selected. If no valid font found, it defaults to {@link MapboxConstants#DEFAULT_FONT}.
- * <p>
- * The font families are checked against the default system fonts defined in
- * &#x27;/system/etc/fonts.xml&#x27; Default font for local ideograph font family is
- * {@link MapboxConstants#DEFAULT_FONT}.
- * </p>
- *
- * @param fontFamilies an array of font families for local ideograph generation.
- * @return This
- */
- @NonNull
- public MapboxMapOptions localIdeographFontFamily(String... fontFamilies) {
- this.localIdeographFontFamily = FontUtils.extractValidFont(fontFamilies);
- return this;
- }
-
- /**
- * Set the custom pixel ratio configuration to override the default value from resources.
- * This ratio will be used to initialise the map with.
- *
- * @param pixelRatio the custom pixel ratio of the map under construction
- * @return This
- */
- @NonNull
- public MapboxMapOptions pixelRatio(float pixelRatio) {
- this.pixelRatio = pixelRatio;
- return this;
- }
-
- /**
- * Check whether tile pre-fetching is enabled.
- *
- * @return true if enabled
- * @deprecated Use {@link #getPrefetchZoomDelta()} instead.
- */
- @Deprecated
- public boolean getPrefetchesTiles() {
- return prefetchesTiles;
- }
-
- /**
- * Check current pre-fetching zoom delta.
- *
- * @return current zoom delta.
- */
- @IntRange(from = 0)
- public int getPrefetchZoomDelta() {
- return prefetchZoomDelta;
- }
-
- /**
- * Check whether cross-source symbol collision detection is enabled.
- *
- * @return true if enabled
- */
- public boolean getCrossSourceCollisions() {
- return crossSourceCollisions;
- }
-
- /**
- * Set the flag to render the map surface on top of another surface.
- *
- * @param renderOnTop true if this map is shown on top of another one, false if bottom.
- */
- public void renderSurfaceOnTop(boolean renderOnTop) {
- this.zMediaOverlay = renderOnTop;
- }
-
- /**
- * Get the flag to render the map surface on top of another surface.
- *
- * @return true if this map is
- */
- public boolean getRenderSurfaceOnTop() {
- return zMediaOverlay;
- }
-
- /**
- * Get the current configured API endpoint base URL.
- *
- * @return Base URL to be used API endpoint.
- * @deprecated use {@link #getApiBaseUri()} instead
- */
- @Deprecated
- public String getApiBaseUrl() {
- return apiBaseUri;
- }
-
- /**
- * Get the current configured API endpoint base URI.
- *
- * @return Base URI to be used API endpoint.
- */
- public String getApiBaseUri() {
- return apiBaseUri;
- }
-
- /**
- * Get the current configured initial camera position for a map view.
- *
- * @return CameraPosition to be initially used.
- */
- public CameraPosition getCamera() {
- return cameraPosition;
- }
-
- /**
- * Get the current configured min zoom for a map view.
- *
- * @return Mininum zoom level to be used.
- */
- public double getMinZoomPreference() {
- return minZoom;
- }
-
- /**
- * Get the current configured maximum zoom for a map view.
- *
- * @return Maximum zoom to be used.
- */
- public double getMaxZoomPreference() {
- return maxZoom;
- }
-
- /**
- * Get the current configured visibility state for mapbox_compass_icon for a map view.
- *
- * @return Visibility state of the mapbox_compass_icon
- */
- public boolean getCompassEnabled() {
- return compassEnabled;
- }
-
- /**
- * Get the current configured gravity state for mapbox_compass_icon for a map view.
- *
- * @return Gravity state of the mapbox_compass_icon
- */
- public int getCompassGravity() {
- return compassGravity;
- }
-
- /**
- * Get the current configured margins for mapbox_compass_icon for a map view.
- *
- * @return Margins state of the mapbox_compass_icon
- */
- public int[] getCompassMargins() {
- return compassMargins;
- }
-
- /**
- * Get the current configured state for fading the mapbox_compass_icon when facing north.
- *
- * @return True if mapbox_compass_icon fades to invisible when facing north
- */
- public boolean getCompassFadeFacingNorth() {
- return fadeCompassFacingNorth;
- }
-
- /**
- * Get the current configured CompassView image.
- *
- * @return the drawable used as compass image
- */
- public Drawable getCompassImage() {
- return compassImage;
- }
-
- /**
- * Get the current configured visibility state for mapbox_compass_icon for a map view.
- *
- * @return Visibility state of the mapbox_compass_icon
- */
- public boolean getLogoEnabled() {
- return logoEnabled;
- }
-
- /**
- * Get the current configured gravity state for logo for a map view.
- *
- * @return Gravity state of the logo
- */
- public int getLogoGravity() {
- return logoGravity;
- }
-
- /**
- * Get the current configured margins for logo for a map view.
- *
- * @return Margins state of the logo
- */
- public int[] getLogoMargins() {
- return logoMargins;
- }
-
- /**
- * Get the current configured rotate gesture state for a map view.
- *
- * @return True indicates gesture is enabled
- */
- public boolean getRotateGesturesEnabled() {
- return rotateGesturesEnabled;
- }
-
- /**
- * Get the current configured scroll gesture state for a map view.
- *
- * @return True indicates gesture is enabled
- */
- public boolean getScrollGesturesEnabled() {
- return scrollGesturesEnabled;
- }
-
- /**
- * Get the current configured tilt gesture state for a map view.
- *
- * @return True indicates gesture is enabled
- */
- public boolean getTiltGesturesEnabled() {
- return tiltGesturesEnabled;
- }
-
- /**
- * Get the current configured zoom gesture state for a map view.
- *
- * @return True indicates gesture is enabled
- */
- public boolean getZoomGesturesEnabled() {
- return zoomGesturesEnabled;
- }
-
- /**
- * Get the current configured double tap gesture state for a map view.
- *
- * @return True indicates gesture is enabled
- */
- public boolean getDoubleTapGesturesEnabled() {
- return doubleTapGesturesEnabled;
- }
-
- /**
- * Get whether the user may zoom the map by tapping twice, holding and moving the pointer up and down.
- *
- * @return True indicates gesture is enabled
- */
- public boolean getQuickZoomGesturesEnabled() {
- return quickZoomGesturesEnabled;
- }
-
- /**
- * Get the current configured visibility state for attribution for a map view.
- *
- * @return Visibility state of the attribution
- */
- public boolean getAttributionEnabled() {
- return attributionEnabled;
- }
-
- /**
- * Get the current configured gravity state for attribution for a map view.
- *
- * @return Gravity state of the logo
- */
- public int getAttributionGravity() {
- return attributionGravity;
- }
-
- /**
- * Get the current configured margins for attribution for a map view.
- *
- * @return Margins state of the logo
- */
- public int[] getAttributionMargins() {
- return attributionMargins;
- }
-
- /**
- * Get the current configured tint color for attribution for a map view.
- *
- * @return the tint color
- */
- @ColorInt
- public int getAttributionTintColor() {
- return attributionTintColor;
- }
-
- /**
- * Get the current configured debug state for a map view.
- *
- * @return True indicates debug is enabled.
- */
- public boolean getDebugActive() {
- return debugActive;
- }
-
- /**
- * Returns true if TextureView is being used the render view.
- *
- * @return True if TextureView is used.
- */
- public boolean getTextureMode() {
- return textureMode;
- }
-
- /**
- * Returns true if TextureView supports a translucent surface
- *
- * @return True if translucent surface is active
- */
- public boolean getTranslucentTextureSurface() {
- return translucentTextureSurface;
- }
-
- /**
- * Returns the current configured foreground color that is used during map creation.
- *
- * @return the load color
- */
- @ColorInt
- public int getForegroundLoadColor() {
- return foregroundLoadColor;
- }
-
- /**
- * Returns the font-family for locally overriding generation of glyphs in the
- * &#x27;CJK Unified Ideographs&#x27; and &#x27;Hangul Syllables&#x27; ranges.
- * Default font for local ideograph font family is {@link MapboxConstants#DEFAULT_FONT}.
- * Returns null if local ideograph font families are disabled.
- *
- * @return Local ideograph font family name.
- */
- @Nullable
- public String getLocalIdeographFontFamily() {
- return localIdeographFontFamilyEnabled ? localIdeographFontFamily : null;
- }
-
- /**
- * Returns true if local ideograph font family is enabled, defaults to true.
- *
- * @return True if local ideograph font family is enabled
- */
- public boolean isLocalIdeographFontFamilyEnabled() {
- return localIdeographFontFamilyEnabled;
- }
-
- /**
- * Return the custom configured pixel ratio, returns 0 if not configured.
- *
- * @return the pixel ratio used by the map under construction
- */
- public float getPixelRatio() {
- return pixelRatio;
- }
-
- public static final Parcelable.Creator<MapboxMapOptions> CREATOR = new Parcelable.Creator<MapboxMapOptions>() {
- public MapboxMapOptions createFromParcel(@NonNull Parcel in) {
- return new MapboxMapOptions(in);
- }
-
- public MapboxMapOptions[] newArray(int size) {
- return new MapboxMapOptions[size];
- }
- };
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(@NonNull Parcel dest, int flags) {
- dest.writeParcelable(cameraPosition, flags);
- dest.writeByte((byte) (debugActive ? 1 : 0));
-
- dest.writeByte((byte) (compassEnabled ? 1 : 0));
- dest.writeInt(compassGravity);
- dest.writeIntArray(compassMargins);
- dest.writeByte((byte) (fadeCompassFacingNorth ? 1 : 0));
- dest.writeParcelable(compassImage != null
- ? BitmapUtils.getBitmapFromDrawable(compassImage) : null, flags);
-
- dest.writeByte((byte) (logoEnabled ? 1 : 0));
- dest.writeInt(logoGravity);
- dest.writeIntArray(logoMargins);
-
- dest.writeByte((byte) (attributionEnabled ? 1 : 0));
- dest.writeInt(attributionGravity);
- dest.writeIntArray(attributionMargins);
- dest.writeInt(attributionTintColor);
-
- dest.writeDouble(minZoom);
- dest.writeDouble(maxZoom);
-
- dest.writeByte((byte) (rotateGesturesEnabled ? 1 : 0));
- dest.writeByte((byte) (scrollGesturesEnabled ? 1 : 0));
- dest.writeByte((byte) (tiltGesturesEnabled ? 1 : 0));
- dest.writeByte((byte) (zoomGesturesEnabled ? 1 : 0));
- dest.writeByte((byte) (doubleTapGesturesEnabled ? 1 : 0));
- dest.writeByte((byte) (quickZoomGesturesEnabled ? 1 : 0));
-
- dest.writeString(apiBaseUri);
- dest.writeByte((byte) (textureMode ? 1 : 0));
- dest.writeByte((byte) (translucentTextureSurface ? 1 : 0));
- dest.writeByte((byte) (prefetchesTiles ? 1 : 0));
- dest.writeInt(prefetchZoomDelta);
- dest.writeByte((byte) (zMediaOverlay ? 1 : 0));
- dest.writeByte((byte) (localIdeographFontFamilyEnabled ? 1 : 0));
- dest.writeString(localIdeographFontFamily);
- dest.writeStringArray(localIdeographFontFamilies);
- dest.writeFloat(pixelRatio);
- dest.writeInt(foregroundLoadColor);
- dest.writeByte((byte) (crossSourceCollisions ? 1 : 0));
- }
-
- @Override
- public boolean equals(@Nullable Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- MapboxMapOptions options = (MapboxMapOptions) o;
-
- if (debugActive != options.debugActive) {
- return false;
- }
- if (compassEnabled != options.compassEnabled) {
- return false;
- }
- if (fadeCompassFacingNorth != options.fadeCompassFacingNorth) {
- return false;
- }
- if (compassImage != null
- ? !compassImage.equals(options.compassImage)
- : options.compassImage != null) {
- return false;
- }
- if (compassGravity != options.compassGravity) {
- return false;
- }
- if (logoEnabled != options.logoEnabled) {
- return false;
- }
- if (logoGravity != options.logoGravity) {
- return false;
- }
- if (attributionTintColor != options.attributionTintColor) {
- return false;
- }
- if (attributionEnabled != options.attributionEnabled) {
- return false;
- }
- if (attributionGravity != options.attributionGravity) {
- return false;
- }
- if (Double.compare(options.minZoom, minZoom) != 0) {
- return false;
- }
- if (Double.compare(options.maxZoom, maxZoom) != 0) {
- return false;
- }
- if (rotateGesturesEnabled != options.rotateGesturesEnabled) {
- return false;
- }
- if (scrollGesturesEnabled != options.scrollGesturesEnabled) {
- return false;
- }
- if (tiltGesturesEnabled != options.tiltGesturesEnabled) {
- return false;
- }
- if (zoomGesturesEnabled != options.zoomGesturesEnabled) {
- return false;
- }
- if (doubleTapGesturesEnabled != options.doubleTapGesturesEnabled) {
- return false;
- }
- if (quickZoomGesturesEnabled != options.quickZoomGesturesEnabled) {
- return false;
- }
- if (cameraPosition != null ? !cameraPosition.equals(options.cameraPosition) : options.cameraPosition != null) {
- return false;
- }
- if (!Arrays.equals(compassMargins, options.compassMargins)) {
- return false;
- }
- if (!Arrays.equals(logoMargins, options.logoMargins)) {
- return false;
- }
- if (!Arrays.equals(attributionMargins, options.attributionMargins)) {
- return false;
- }
- if (apiBaseUri != null ? !apiBaseUri.equals(options.apiBaseUri) : options.apiBaseUri != null) {
- return false;
- }
- if (prefetchesTiles != options.prefetchesTiles) {
- return false;
- }
- if (prefetchZoomDelta != options.prefetchZoomDelta) {
- return false;
- }
- if (zMediaOverlay != options.zMediaOverlay) {
- return false;
- }
- if (localIdeographFontFamilyEnabled != options.localIdeographFontFamilyEnabled) {
- return false;
- }
- if (!localIdeographFontFamily.equals(options.localIdeographFontFamily)) {
- return false;
- }
- if (!Arrays.equals(localIdeographFontFamilies, options.localIdeographFontFamilies)) {
- return false;
- }
-
- if (pixelRatio != options.pixelRatio) {
- return false;
- }
-
- if (crossSourceCollisions != options.crossSourceCollisions) {
- return false;
- }
-
- return false;
- }
-
- @Override
- public int hashCode() {
- int result;
- long temp;
- result = cameraPosition != null ? cameraPosition.hashCode() : 0;
- result = 31 * result + (debugActive ? 1 : 0);
- result = 31 * result + (compassEnabled ? 1 : 0);
- result = 31 * result + (fadeCompassFacingNorth ? 1 : 0);
- result = 31 * result + compassGravity;
- result = 31 * result + (compassImage != null ? compassImage.hashCode() : 0);
- result = 31 * result + Arrays.hashCode(compassMargins);
- result = 31 * result + (logoEnabled ? 1 : 0);
- result = 31 * result + logoGravity;
- result = 31 * result + Arrays.hashCode(logoMargins);
- result = 31 * result + attributionTintColor;
- result = 31 * result + (attributionEnabled ? 1 : 0);
- result = 31 * result + attributionGravity;
- result = 31 * result + Arrays.hashCode(attributionMargins);
- temp = Double.doubleToLongBits(minZoom);
- result = 31 * result + (int) (temp ^ (temp >>> 32));
- temp = Double.doubleToLongBits(maxZoom);
- result = 31 * result + (int) (temp ^ (temp >>> 32));
- result = 31 * result + (rotateGesturesEnabled ? 1 : 0);
- result = 31 * result + (scrollGesturesEnabled ? 1 : 0);
- result = 31 * result + (tiltGesturesEnabled ? 1 : 0);
- result = 31 * result + (zoomGesturesEnabled ? 1 : 0);
- result = 31 * result + (doubleTapGesturesEnabled ? 1 : 0);
- result = 31 * result + (quickZoomGesturesEnabled ? 1 : 0);
- result = 31 * result + (apiBaseUri != null ? apiBaseUri.hashCode() : 0);
- result = 31 * result + (textureMode ? 1 : 0);
- result = 31 * result + (translucentTextureSurface ? 1 : 0);
- result = 31 * result + (prefetchesTiles ? 1 : 0);
- result = 31 * result + prefetchZoomDelta;
- result = 31 * result + (zMediaOverlay ? 1 : 0);
- result = 31 * result + (localIdeographFontFamilyEnabled ? 1 : 0);
- result = 31 * result + (localIdeographFontFamily != null ? localIdeographFontFamily.hashCode() : 0);
- result = 31 * result + Arrays.hashCode(localIdeographFontFamilies);
- result = 31 * result + (int) pixelRatio;
- result = 31 * result + (crossSourceCollisions ? 1 : 0);
- return result;
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MarkerContainer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MarkerContainer.java
deleted file mode 100644
index b408d9f5c5..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MarkerContainer.java
+++ /dev/null
@@ -1,146 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.graphics.RectF;
-import android.support.annotation.NonNull;
-import android.support.v4.util.LongSparseArray;
-
-import com.mapbox.mapboxsdk.annotations.Annotation;
-import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
-import com.mapbox.mapboxsdk.annotations.Icon;
-import com.mapbox.mapboxsdk.annotations.Marker;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Encapsulates {@link Marker}'s functionality.
- */
-class MarkerContainer implements Markers {
-
- private final NativeMap nativeMapView;
- private final LongSparseArray<Annotation> annotations;
- private final IconManager iconManager;
-
- MarkerContainer(NativeMap nativeMapView, LongSparseArray<Annotation> annotations, IconManager iconManager) {
- this.nativeMapView = nativeMapView;
- this.annotations = annotations;
- this.iconManager = iconManager;
- }
-
- @Override
- public Marker addBy(@NonNull BaseMarkerOptions markerOptions, @NonNull MapboxMap mapboxMap) {
- Marker marker = prepareMarker(markerOptions);
- long id = nativeMapView != null ? nativeMapView.addMarker(marker) : 0;
- marker.setMapboxMap(mapboxMap);
- marker.setId(id);
- annotations.put(id, marker);
- return marker;
- }
-
- @NonNull
- @Override
- public List<Marker> addBy(@NonNull List<? extends BaseMarkerOptions> markerOptionsList, @NonNull MapboxMap
- mapboxMap) {
- int count = markerOptionsList.size();
- List<Marker> markers = new ArrayList<>(count);
- if (nativeMapView != null && count > 0) {
- BaseMarkerOptions markerOptions;
- Marker marker;
- for (int i = 0; i < count; i++) {
- markerOptions = markerOptionsList.get(i);
- marker = prepareMarker(markerOptions);
- markers.add(marker);
- }
-
- if (markers.size() > 0) {
- long[] ids = nativeMapView.addMarkers(markers);
- for (int i = 0; i < ids.length; i++) {
- Marker createdMarker = markers.get(i);
- createdMarker.setMapboxMap(mapboxMap);
- createdMarker.setId(ids[i]);
- annotations.put(ids[i], createdMarker);
- }
- }
- }
- return markers;
- }
-
- @Override
- public void update(@NonNull Marker updatedMarker, @NonNull MapboxMap mapboxMap) {
- ensureIconLoaded(updatedMarker, mapboxMap);
- nativeMapView.updateMarker(updatedMarker);
- annotations.setValueAt(annotations.indexOfKey(updatedMarker.getId()), updatedMarker);
- }
-
- @NonNull
- @Override
- public List<Marker> obtainAll() {
- List<Marker> markers = new ArrayList<>();
- Annotation annotation;
- for (int i = 0; i < annotations.size(); i++) {
- annotation = annotations.get(annotations.keyAt(i));
- if (annotation instanceof Marker) {
- markers.add((Marker) annotation);
- }
- }
- return markers;
- }
-
- @NonNull
- @Override
- public List<Marker> obtainAllIn(@NonNull RectF rectangle) {
- RectF rect = nativeMapView.getDensityDependantRectangle(rectangle);
- long[] ids = nativeMapView.queryPointAnnotations(rect);
- List<Long> idsList = new ArrayList<>(ids.length);
- for (long id : ids) {
- idsList.add(id);
- }
-
- List<Marker> annotations = new ArrayList<>(ids.length);
- List<Annotation> annotationList = obtainAnnotations();
- int count = annotationList.size();
- for (int i = 0; i < count; i++) {
- Annotation annotation = annotationList.get(i);
- if (annotation instanceof com.mapbox.mapboxsdk.annotations.Marker && idsList.contains(annotation.getId())) {
- annotations.add((com.mapbox.mapboxsdk.annotations.Marker) annotation);
- }
- }
-
- return new ArrayList<>(annotations);
- }
-
- @Override
- public void reload() {
- iconManager.reloadIcons();
- int count = annotations.size();
- for (int i = 0; i < count; i++) {
- Annotation annotation = annotations.get(i);
- if (annotation instanceof Marker) {
- Marker marker = (Marker) annotation;
- nativeMapView.removeAnnotation(annotation.getId());
- long newId = nativeMapView.addMarker(marker);
- marker.setId(newId);
- }
- }
- }
-
- private Marker prepareMarker(BaseMarkerOptions markerOptions) {
- Marker marker = markerOptions.getMarker();
- Icon icon = iconManager.loadIconForMarker(marker);
- marker.setTopOffsetPixels(iconManager.getTopOffsetPixelsForIcon(icon));
- return marker;
- }
-
- private void ensureIconLoaded(Marker marker, @NonNull MapboxMap mapboxMap) {
- iconManager.ensureIconLoaded(marker, mapboxMap);
- }
-
- @NonNull
- private List<Annotation> obtainAnnotations() {
- List<Annotation> annotations = new ArrayList<>();
- for (int i = 0; i < this.annotations.size(); i++) {
- annotations.add(this.annotations.get(this.annotations.keyAt(i)));
- }
- return annotations;
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Markers.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Markers.java
deleted file mode 100644
index 62859d58a8..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Markers.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.graphics.RectF;
-import android.support.annotation.NonNull;
-
-import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
-import com.mapbox.mapboxsdk.annotations.Marker;
-
-import java.util.List;
-
-/**
- * Interface that defines convenient methods for working with a {@link Marker}'s collection.
- */
-interface Markers {
- Marker addBy(@NonNull BaseMarkerOptions markerOptions, @NonNull MapboxMap mapboxMap);
-
- List<Marker> addBy(@NonNull List<? extends BaseMarkerOptions> markerOptionsList, @NonNull MapboxMap mapboxMap);
-
- void update(@NonNull Marker updatedMarker, @NonNull MapboxMap mapboxMap);
-
- List<Marker> obtainAll();
-
- @NonNull
- List<Marker> obtainAllIn(@NonNull RectF rectangle);
-
- void reload();
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMap.java
deleted file mode 100644
index c805dcddb0..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMap.java
+++ /dev/null
@@ -1,274 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.graphics.Bitmap;
-import android.graphics.PointF;
-import android.graphics.RectF;
-import android.support.annotation.IntRange;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-
-import com.mapbox.geojson.Feature;
-import com.mapbox.geojson.Geometry;
-import com.mapbox.mapboxsdk.annotations.Marker;
-import com.mapbox.mapboxsdk.annotations.Polygon;
-import com.mapbox.mapboxsdk.annotations.Polyline;
-import com.mapbox.mapboxsdk.camera.CameraPosition;
-import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.geometry.LatLngBounds;
-import com.mapbox.mapboxsdk.geometry.ProjectedMeters;
-import com.mapbox.mapboxsdk.style.expressions.Expression;
-import com.mapbox.mapboxsdk.style.layers.Layer;
-import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
-import com.mapbox.mapboxsdk.style.light.Light;
-import com.mapbox.mapboxsdk.style.sources.Source;
-
-import java.util.List;
-
-interface NativeMap {
-
- //
- // Lifecycle API
- //
-
- void resizeView(int width, int height);
-
- void onLowMemory();
-
- void destroy();
-
- boolean isDestroyed();
-
- //
- // Camera API
- //
-
- void jumpTo(@NonNull LatLng center, double zoom, double pitch, double bearing, double[] padding);
-
- void easeTo(@NonNull LatLng center, double zoom, double bearing, double pitch, double[] padding, long duration,
- boolean easingInterpolator);
-
- void flyTo(@NonNull LatLng center, double zoom, double bearing, double pitch, double[] padding, long duration);
-
- void moveBy(double deltaX, double deltaY, long duration);
-
- @NonNull
- CameraPosition getCameraPosition();
-
- CameraPosition getCameraForLatLngBounds(@NonNull LatLngBounds bounds, int[] padding, double bearing, double pitch);
-
- CameraPosition getCameraForGeometry(@NonNull Geometry geometry, int[] padding, double bearing, double pitch);
-
- void resetPosition();
-
- void setLatLng(@NonNull LatLng latLng, long duration);
-
- LatLng getLatLng();
-
- void setLatLngBounds(@Nullable LatLngBounds latLngBounds);
-
- void setVisibleCoordinateBounds(@NonNull LatLng[] coordinates, @NonNull RectF padding,
- double direction, long duration);
-
- void setPitch(double pitch, long duration);
-
- double getPitch();
-
- void setZoom(double zoom, @NonNull PointF focalPoint, long duration);
-
- double getZoom();
-
- void setMinZoom(double zoom);
-
- double getMinZoom();
-
- void setMaxZoom(double zoom);
-
- double getMaxZoom();
-
- void resetZoom();
-
- void rotateBy(double sx, double sy, double ex, double ey, long duration);
-
- void setBearing(double degrees, long duration);
-
- void setBearing(double degrees, double fx, double fy, long duration);
-
- double getBearing();
-
- void resetNorth();
-
- void cancelTransitions();
-
- //
- // Style API
- //
-
- void setStyleUri(String url);
-
- @NonNull
- String getStyleUri();
-
- void setStyleJson(String newStyleJson);
-
- @NonNull
- String getStyleJson();
-
- boolean isFullyLoaded();
-
- void addLayer(@NonNull Layer layer);
-
- void addLayerBelow(@NonNull Layer layer, @NonNull String below);
-
- void addLayerAbove(@NonNull Layer layer, @NonNull String above);
-
- void addLayerAt(@NonNull Layer layer, @IntRange(from = 0) int index);
-
- @NonNull
- List<Layer> getLayers();
-
- Layer getLayer(String layerId);
-
- boolean removeLayer(@NonNull String layerId);
-
- boolean removeLayer(@NonNull Layer layer);
-
- boolean removeLayerAt(@IntRange(from = 0) int index);
-
- void addSource(@NonNull Source source);
-
- @NonNull
- List<Source> getSources();
-
- Source getSource(@NonNull String sourceId);
-
- boolean removeSource(@NonNull String sourceId);
-
- boolean removeSource(@NonNull Source source);
-
- void setTransitionOptions(@NonNull TransitionOptions transitionOptions);
-
- @NonNull
- TransitionOptions getTransitionOptions();
-
- void addImages(Image[] images);
-
- Bitmap getImage(String name);
-
- void removeImage(String name);
-
- Light getLight();
-
- //
- // Content padding API
- //
-
- void setContentPadding(double[] padding);
-
- double[] getContentPadding();
-
- //
- // Query API
- //
-
- @NonNull
- List<Feature> queryRenderedFeatures(@NonNull PointF coordinates,
- @Nullable String[] layerIds,
- @Nullable Expression filter);
-
- @NonNull
- List<Feature> queryRenderedFeatures(@NonNull RectF coordinates,
- @Nullable String[] layerIds,
- @Nullable Expression filter);
-
- //
- // Projection API
- //
-
- double getMetersPerPixelAtLatitude(double lat);
-
- ProjectedMeters projectedMetersForLatLng(@NonNull LatLng latLng);
-
- LatLng latLngForProjectedMeters(@NonNull ProjectedMeters projectedMeters);
-
- @NonNull
- PointF pixelForLatLng(@NonNull LatLng latLng);
-
- LatLng latLngForPixel(@NonNull PointF pixel);
-
- //
- // Utils API
- //
-
- void setOnFpsChangedListener(@NonNull MapboxMap.OnFpsChangedListener listener);
-
- void setDebug(boolean debug);
-
- boolean getDebug();
-
- void cycleDebugOptions();
-
- void setReachability(boolean status);
-
- void setApiBaseUrl(String baseUrl);
-
- void setPrefetchTiles(boolean enable);
-
- boolean getPrefetchTiles();
-
- void setPrefetchZoomDelta(@IntRange(from = 0) int delta);
-
- @IntRange(from = 0)
- int getPrefetchZoomDelta();
-
- void setGestureInProgress(boolean inProgress);
-
- float getPixelRatio();
-
- //
- // Deprecated Annotations API
- //
-
- long addMarker(Marker marker);
-
- @NonNull
- long[] addMarkers(@NonNull List<Marker> markers);
-
- long addPolyline(Polyline polyline);
-
- @NonNull
- long[] addPolylines(@NonNull List<Polyline> polylines);
-
- long addPolygon(Polygon polygon);
-
- @NonNull
- long[] addPolygons(@NonNull List<Polygon> polygons);
-
- void updateMarker(@NonNull Marker marker);
-
- void updatePolygon(@NonNull Polygon polygon);
-
- void updatePolyline(@NonNull Polyline polyline);
-
- void removeAnnotation(long id);
-
- void removeAnnotations(long[] ids);
-
- double getTopOffsetPixelsForAnnotationSymbol(String symbolName);
-
- void addAnnotationIcon(String symbol, int width, int height, float scale, byte[] pixels);
-
- void removeAnnotationIcon(String symbol);
-
- @NonNull
- long[] queryPointAnnotations(RectF rectF);
-
- @NonNull
- long[] queryShapeAnnotations(RectF rectF);
-
- @NonNull
- RectF getDensityDependantRectangle(RectF rectangle);
-
- long getNativePtr();
-
- void addSnapshotCallback(@NonNull MapboxMap.SnapshotReadyCallback callback);
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
deleted file mode 100755
index 75ca5edfca..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java
+++ /dev/null
@@ -1,1512 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.PointF;
-import android.graphics.RectF;
-import android.os.Handler;
-import android.support.annotation.IntRange;
-import android.support.annotation.Keep;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.text.TextUtils;
-
-import com.mapbox.geojson.Feature;
-import com.mapbox.geojson.Geometry;
-import com.mapbox.mapboxsdk.LibraryLoader;
-import com.mapbox.mapboxsdk.MapStrictMode;
-import com.mapbox.mapboxsdk.annotations.Icon;
-import com.mapbox.mapboxsdk.annotations.Marker;
-import com.mapbox.mapboxsdk.annotations.Polygon;
-import com.mapbox.mapboxsdk.annotations.Polyline;
-import com.mapbox.mapboxsdk.camera.CameraPosition;
-import com.mapbox.mapboxsdk.exceptions.CalledFromWorkerThreadException;
-import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.geometry.LatLngBounds;
-import com.mapbox.mapboxsdk.geometry.ProjectedMeters;
-import com.mapbox.mapboxsdk.log.Logger;
-import com.mapbox.mapboxsdk.maps.renderer.MapRenderer;
-import com.mapbox.mapboxsdk.storage.FileSource;
-import com.mapbox.mapboxsdk.style.expressions.Expression;
-import com.mapbox.mapboxsdk.style.layers.CannotAddLayerException;
-import com.mapbox.mapboxsdk.style.layers.Layer;
-import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
-import com.mapbox.mapboxsdk.style.light.Light;
-import com.mapbox.mapboxsdk.style.sources.CannotAddSourceException;
-import com.mapbox.mapboxsdk.style.sources.Source;
-import com.mapbox.mapboxsdk.utils.BitmapUtils;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-// Class that wraps the native methods for convenience
-final class NativeMapView implements NativeMap {
-
- private static final String TAG = "Mbgl-NativeMapView";
-
- // Hold a reference to prevent it from being GC'd as long as it's used on the native side
- private final FileSource fileSource;
-
- // Used to schedule work on the MapRenderer Thread
- private final MapRenderer mapRenderer;
-
- // Used to validate if methods are called from the correct thread
- @NonNull
- private final Thread thread;
-
- // Used for view callbacks
- @Nullable
- private ViewCallback viewCallback;
-
- // Used for map change callbacks
- @Nullable
- private StateCallback stateCallback;
-
- // Device density
- private final float pixelRatio;
-
- // Flag to indicate destroy was called
- private boolean destroyed = false;
-
- // Cached to enable lazily set padding.
- // Whenever an animation is schedule, this value is cleared and the source of truth becomes the core transform state.
- private double[] edgeInsets;
-
- // Holds the pointer to JNI NativeMapView
- @Keep
- private long nativePtr = 0;
-
- // Listener invoked to return a bitmap of the map
- private MapboxMap.SnapshotReadyCallback snapshotReadyCallback;
-
- static {
- LibraryLoader.load();
- }
-
- //
- // Constructors
- //
-
- public NativeMapView(@NonNull final Context context, final boolean crossSourceCollisions,
- final ViewCallback viewCallback, final StateCallback stateCallback,
- final MapRenderer mapRenderer) {
- this(context, context.getResources().getDisplayMetrics().density, crossSourceCollisions, viewCallback,
- stateCallback, mapRenderer);
- }
-
- public NativeMapView(final Context context, final float pixelRatio, final boolean crossSourceCollisions,
- final ViewCallback viewCallback, final StateCallback stateCallback,
- final MapRenderer mapRenderer) {
- this.mapRenderer = mapRenderer;
- this.viewCallback = viewCallback;
- this.fileSource = FileSource.getInstance(context);
- this.pixelRatio = pixelRatio;
- this.thread = Thread.currentThread();
- this.stateCallback = stateCallback;
- nativeInitialize(this, fileSource, mapRenderer, pixelRatio, crossSourceCollisions);
- }
-
- //
- // Methods
- //
-
- private boolean checkState(String callingMethod) {
- // validate if invocation has occurred on the main thread
- if (thread != Thread.currentThread()) {
- throw new CalledFromWorkerThreadException(
- String.format(
- "Map interactions should happen on the UI thread. Method invoked from wrong thread is %s.",
- callingMethod)
- );
- }
-
- // validate if map has already been destroyed
- if (destroyed && !TextUtils.isEmpty(callingMethod)) {
- String message = String.format(
- "You're calling `%s` after the `MapView` was destroyed, were you invoking it after `onDestroy()`?",
- callingMethod);
- Logger.e(TAG, message);
-
- MapStrictMode.strictModeViolation(message);
- }
- return destroyed;
- }
-
- @Override
- public void destroy() {
- destroyed = true;
- viewCallback = null;
- nativeDestroy();
- }
-
- @Override
- public void resizeView(int width, int height) {
- if (checkState("resizeView")) {
- return;
- }
- width = (int) Math.ceil(width / pixelRatio);
- height = (int) Math.ceil(height / pixelRatio);
-
- if (width < 0) {
- throw new IllegalArgumentException("width cannot be negative.");
- }
-
- if (height < 0) {
- throw new IllegalArgumentException("height cannot be negative.");
- }
-
- if (width > 65535) {
- // we have seen edge cases where devices return incorrect values #6111
- Logger.e(TAG, String.format("Device returned an out of range width size, "
- + "capping value at 65535 instead of %s", width)
- );
- width = 65535;
- }
-
- if (height > 65535) {
- // we have seen edge cases where devices return incorrect values #6111
- Logger.e(TAG, String.format("Device returned an out of range height size, "
- + "capping value at 65535 instead of %s", height)
- );
- height = 65535;
- }
-
- nativeResizeView(width, height);
- }
-
- @Override
- public void setStyleUri(String url) {
- if (checkState("setStyleUri")) {
- return;
- }
- nativeSetStyleUrl(url);
- }
-
- @Override
- @NonNull
- public String getStyleUri() {
- if (checkState("getStyleUri")) {
- return "";
- }
- return nativeGetStyleUrl();
- }
-
- @Override
- public void setStyleJson(String newStyleJson) {
- if (checkState("setStyleJson")) {
- return;
- }
- nativeSetStyleJson(newStyleJson);
- }
-
- @Override
- @NonNull
- public String getStyleJson() {
- if (checkState("getStyleJson")) {
- return "";
- }
- return nativeGetStyleJson();
- }
-
- @Override
- public void setLatLngBounds(LatLngBounds latLngBounds) {
- if (checkState("setLatLngBounds")) {
- return;
- }
- nativeSetLatLngBounds(latLngBounds);
- }
-
- @Override
- public void cancelTransitions() {
- if (checkState("cancelTransitions")) {
- return;
- }
- nativeCancelTransitions();
- }
-
- @Override
- public void setGestureInProgress(boolean inProgress) {
- if (checkState("setGestureInProgress")) {
- return;
- }
- nativeSetGestureInProgress(inProgress);
- }
-
- @Override
- public void moveBy(double dx, double dy, long duration) {
- if (checkState("moveBy")) {
- return;
- }
- nativeMoveBy(dx / pixelRatio, dy / pixelRatio, duration);
- }
-
- @Override
- public void setLatLng(@NonNull LatLng latLng, long duration) {
- if (checkState("setLatLng")) {
- return;
- }
- nativeSetLatLng(latLng.getLatitude(), latLng.getLongitude(),
- getAnimationPaddingAndClearCachedInsets(null), duration);
- }
-
- @Override
- public LatLng getLatLng() {
- if (checkState("")) {
- return new LatLng();
- }
- return nativeGetLatLng();
- }
-
- @Override
- public CameraPosition getCameraForLatLngBounds(LatLngBounds bounds, int[] padding, double bearing, double tilt) {
- if (checkState("getCameraForLatLngBounds")) {
- return null;
- }
- return nativeGetCameraForLatLngBounds(
- bounds,
- padding[1] / pixelRatio,
- padding[0] / pixelRatio,
- padding[3] / pixelRatio,
- padding[2] / pixelRatio,
- bearing,
- tilt
- );
- }
-
- @Override
- public CameraPosition getCameraForGeometry(Geometry geometry, int[] padding, double bearing, double tilt) {
- if (checkState("getCameraForGeometry")) {
- return null;
- }
- return nativeGetCameraForGeometry(
- geometry,
- padding[1] / pixelRatio,
- padding[0] / pixelRatio,
- padding[3] / pixelRatio,
- padding[2] / pixelRatio,
- bearing,
- tilt
- );
- }
-
- @Override
- public void resetPosition() {
- if (checkState("resetPosition")) {
- return;
- }
- nativeResetPosition();
- }
-
- @Override
- public double getPitch() {
- if (checkState("getPitch")) {
- return 0;
- }
- return nativeGetPitch();
- }
-
- @Override
- public void setPitch(double pitch, long duration) {
- if (checkState("setPitch")) {
- return;
- }
- nativeSetPitch(pitch, duration);
- }
-
- @Override
- public void setZoom(double zoom, @NonNull PointF focalPoint, long duration) {
- if (checkState("setZoom")) {
- return;
- }
- nativeSetZoom(zoom, focalPoint.x / pixelRatio, focalPoint.y / pixelRatio, duration);
- }
-
- @Override
- public double getZoom() {
- if (checkState("getZoom")) {
- return 0;
- }
- return nativeGetZoom();
- }
-
- @Override
- public void resetZoom() {
- if (checkState("resetZoom")) {
- return;
- }
- nativeResetZoom();
- }
-
- @Override
- public void setMinZoom(double zoom) {
- if (checkState("setMinZoom")) {
- return;
- }
- nativeSetMinZoom(zoom);
- }
-
- @Override
- public double getMinZoom() {
- if (checkState("getMinZoom")) {
- return 0;
- }
- return nativeGetMinZoom();
- }
-
- @Override
- public void setMaxZoom(double zoom) {
- if (checkState("setMaxZoom")) {
- return;
- }
- nativeSetMaxZoom(zoom);
- }
-
- @Override
- public double getMaxZoom() {
- if (checkState("getMaxZoom")) {
- return 0;
- }
- return nativeGetMaxZoom();
- }
-
- @Override
- public void rotateBy(double sx, double sy, double ex, double ey,
- long duration) {
- if (checkState("rotateBy")) {
- return;
- }
- nativeRotateBy(sx / pixelRatio, sy / pixelRatio, ex, ey, duration);
- }
-
- @Override
- public void setContentPadding(double[] padding) {
- if (checkState("setContentPadding")) {
- return;
- }
- this.edgeInsets = padding;
- }
-
- @Override
- public double[] getContentPadding() {
- if (checkState("getContentPadding")) {
- return new double[] {0, 0, 0, 0};
- }
- // if cached insets are not applied yet, return them, otherwise, get the padding from the camera
- return edgeInsets != null ? edgeInsets : getCameraPosition().padding;
- }
-
- @Override
- public void setBearing(double degrees, long duration) {
- if (checkState("setBearing")) {
- return;
- }
- nativeSetBearing(degrees, duration);
- }
-
- @Override
- public void setBearing(double degrees, double fx, double fy, long duration) {
- if (checkState("setBearing")) {
- return;
- }
- nativeSetBearingXY(degrees, fx / pixelRatio, fy / pixelRatio, duration);
- }
-
- @Override
- public double getBearing() {
- if (checkState("getBearing")) {
- return 0;
- }
- return nativeGetBearing();
- }
-
- @Override
- public void resetNorth() {
- if (checkState("resetNorth")) {
- return;
- }
- nativeResetNorth();
- }
-
- @Override
- public long addMarker(Marker marker) {
- if (checkState("addMarker")) {
- return 0;
- }
- Marker[] markers = {marker};
- return nativeAddMarkers(markers)[0];
- }
-
- @Override
- @NonNull
- public long[] addMarkers(@NonNull List<Marker> markers) {
- if (checkState("addMarkers")) {
- return new long[] {};
- }
- return nativeAddMarkers(markers.toArray(new Marker[markers.size()]));
- }
-
- @Override
- public long addPolyline(Polyline polyline) {
- if (checkState("addPolyline")) {
- return 0;
- }
- Polyline[] polylines = {polyline};
- return nativeAddPolylines(polylines)[0];
- }
-
- @Override
- @NonNull
- public long[] addPolylines(@NonNull List<Polyline> polylines) {
- if (checkState("addPolylines")) {
- return new long[] {};
- }
- return nativeAddPolylines(polylines.toArray(new Polyline[polylines.size()]));
- }
-
- @Override
- public long addPolygon(Polygon polygon) {
- if (checkState("addPolygon")) {
- return 0;
- }
- Polygon[] polygons = {polygon};
- return nativeAddPolygons(polygons)[0];
- }
-
- @Override
- @NonNull
- public long[] addPolygons(@NonNull List<Polygon> polygons) {
- if (checkState("addPolygons")) {
- return new long[] {};
- }
- return nativeAddPolygons(polygons.toArray(new Polygon[polygons.size()]));
- }
-
- @Override
- public void updateMarker(@NonNull Marker marker) {
- if (checkState("updateMarker")) {
- return;
- }
- LatLng position = marker.getPosition();
- Icon icon = marker.getIcon();
- nativeUpdateMarker(marker.getId(), position.getLatitude(), position.getLongitude(), icon.getId());
- }
-
- @Override
- public void updatePolygon(@NonNull Polygon polygon) {
- if (checkState("updatePolygon")) {
- return;
- }
- nativeUpdatePolygon(polygon.getId(), polygon);
- }
-
- @Override
- public void updatePolyline(@NonNull Polyline polyline) {
- if (checkState("updatePolyline")) {
- return;
- }
- nativeUpdatePolyline(polyline.getId(), polyline);
- }
-
- @Override
- public void removeAnnotation(long id) {
- if (checkState("removeAnnotation")) {
- return;
- }
- long[] ids = {id};
- removeAnnotations(ids);
- }
-
- @Override
- public void removeAnnotations(long[] ids) {
- if (checkState("removeAnnotations")) {
- return;
- }
- nativeRemoveAnnotations(ids);
- }
-
- @Override
- @NonNull
- public long[] queryPointAnnotations(RectF rect) {
- if (checkState("queryPointAnnotations")) {
- return new long[] {};
- }
- return nativeQueryPointAnnotations(rect);
- }
-
- @Override
- @NonNull
- public long[] queryShapeAnnotations(RectF rectF) {
- if (checkState("queryShapeAnnotations")) {
- return new long[] {};
- }
- return nativeQueryShapeAnnotations(rectF);
- }
-
- @Override
- public void addAnnotationIcon(String symbol, int width, int height, float scale, byte[] pixels) {
- if (checkState("addAnnotationIcon")) {
- return;
- }
- nativeAddAnnotationIcon(symbol, width, height, scale, pixels);
- }
-
- @Override
- public void removeAnnotationIcon(String symbol) {
- if (checkState("removeAnnotationIcon")) {
- return;
- }
- nativeRemoveAnnotationIcon(symbol);
- }
-
- @Override
- public void setVisibleCoordinateBounds(LatLng[] coordinates, RectF padding, double direction, long duration) {
- if (checkState("setVisibleCoordinateBounds")) {
- return;
- }
- nativeSetVisibleCoordinateBounds(coordinates, padding, direction, duration);
- }
-
- @Override
- public void onLowMemory() {
- if (checkState("onLowMemory")) {
- return;
- }
- nativeOnLowMemory();
- }
-
- @Override
- public void setDebug(boolean debug) {
- if (checkState("setDebug")) {
- return;
- }
- nativeSetDebug(debug);
- }
-
- @Override
- public void cycleDebugOptions() {
- if (checkState("cycleDebugOptions")) {
- return;
- }
- nativeCycleDebugOptions();
- }
-
- @Override
- public boolean getDebug() {
- if (checkState("getDebug")) {
- return false;
- }
- return nativeGetDebug();
- }
-
- @Override
- public boolean isFullyLoaded() {
- if (checkState("isFullyLoaded")) {
- return false;
- }
- return nativeIsFullyLoaded();
- }
-
- @Override
- public void setReachability(boolean status) {
- if (checkState("setReachability")) {
- return;
- }
- nativeSetReachability(status);
- }
-
- @Override
- public double getMetersPerPixelAtLatitude(double lat) {
- if (checkState("getMetersPerPixelAtLatitude")) {
- return 0;
- }
- return nativeGetMetersPerPixelAtLatitude(lat, getZoom());
- }
-
- @Override
- public ProjectedMeters projectedMetersForLatLng(@NonNull LatLng latLng) {
- if (checkState("projectedMetersForLatLng")) {
- return null;
- }
- return nativeProjectedMetersForLatLng(latLng.getLatitude(), latLng.getLongitude());
- }
-
- @Override
- public LatLng latLngForProjectedMeters(@NonNull ProjectedMeters projectedMeters) {
- if (checkState("latLngForProjectedMeters")) {
- return new LatLng();
- }
- return nativeLatLngForProjectedMeters(projectedMeters.getNorthing(),
- projectedMeters.getEasting());
- }
-
- @Override
- @NonNull
- public PointF pixelForLatLng(@NonNull LatLng latLng) {
- if (checkState("pixelForLatLng")) {
- return new PointF();
- }
- PointF pointF = nativePixelForLatLng(latLng.getLatitude(), latLng.getLongitude());
- pointF.set(pointF.x * pixelRatio, pointF.y * pixelRatio);
- return pointF;
- }
-
- @Override
- public LatLng latLngForPixel(@NonNull PointF pixel) {
- if (checkState("latLngForPixel")) {
- return new LatLng();
- }
- return nativeLatLngForPixel(pixel.x / pixelRatio, pixel.y / pixelRatio);
- }
-
- @Override
- public double getTopOffsetPixelsForAnnotationSymbol(String symbolName) {
- if (checkState("getTopOffsetPixelsForAnnotationSymbol")) {
- return 0;
- }
- return nativeGetTopOffsetPixelsForAnnotationSymbol(symbolName);
- }
-
- @Override
- public void jumpTo(@NonNull LatLng center, double zoom, double pitch, double angle, double[] padding) {
- if (checkState("jumpTo")) {
- return;
- }
- nativeJumpTo(angle, center.getLatitude(), center.getLongitude(), pitch, zoom,
- getAnimationPaddingAndClearCachedInsets(padding));
- }
-
- @Override
- public void easeTo(@NonNull LatLng center, double zoom, double angle, double pitch, double[] padding, long duration,
- boolean easingInterpolator) {
- if (checkState("easeTo")) {
- return;
- }
- nativeEaseTo(angle, center.getLatitude(), center.getLongitude(), duration, pitch, zoom,
- getAnimationPaddingAndClearCachedInsets(padding), easingInterpolator);
- }
-
- @Override
- public void flyTo(@NonNull LatLng center, double zoom, double angle, double pitch, double[] padding, long duration) {
- if (checkState("flyTo")) {
- return;
- }
- nativeFlyTo(angle, center.getLatitude(), center.getLongitude(), duration, pitch, zoom,
- getAnimationPaddingAndClearCachedInsets(padding));
- }
-
- @Override
- @NonNull
- public CameraPosition getCameraPosition() {
- if (checkState("getCameraValues")) {
- return new CameraPosition.Builder().build();
- }
- if (edgeInsets != null) {
- return new CameraPosition.Builder(nativeGetCameraPosition()).padding(edgeInsets).build();
- } else {
- return nativeGetCameraPosition();
- }
- }
-
- @Override
- public void setPrefetchTiles(boolean enable) {
- if (checkState("setPrefetchTiles")) {
- return;
- }
- nativeSetPrefetchTiles(enable);
- }
-
- @Override
- public boolean getPrefetchTiles() {
- if (checkState("getPrefetchTiles")) {
- return false;
- }
- return nativeGetPrefetchTiles();
- }
-
- @Override
- public void setPrefetchZoomDelta(@IntRange(from = 0) int delta) {
- if (checkState("nativeSetPrefetchZoomDelta")) {
- return;
- }
- nativeSetPrefetchZoomDelta(delta);
- }
-
- @Override
- @IntRange(from = 0)
- public int getPrefetchZoomDelta() {
- if (checkState("nativeGetPrefetchZoomDelta")) {
- return 0;
- }
- return nativeGetPrefetchZoomDelta();
- }
-
- // Runtime style Api
-
- @Override
- public void setTransitionOptions(@NonNull TransitionOptions transitionOptions) {
- nativeSetTransitionOptions(transitionOptions);
- }
-
- @NonNull
- @Override
- public TransitionOptions getTransitionOptions() {
- return nativeGetTransitionOptions();
- }
-
- @Override
- @NonNull
- public List<Layer> getLayers() {
- if (checkState("getLayers")) {
- return new ArrayList<>();
- }
- return Arrays.asList(nativeGetLayers());
- }
-
- @Override
- public Layer getLayer(String layerId) {
- if (checkState("getLayer")) {
- return null;
- }
- return nativeGetLayer(layerId);
- }
-
- @Override
- public void addLayer(@NonNull Layer layer) {
- if (checkState("addLayer")) {
- return;
- }
- nativeAddLayer(layer.getNativePtr(), null);
- }
-
- @Override
- public void addLayerBelow(@NonNull Layer layer, @NonNull String below) {
- if (checkState("addLayerBelow")) {
- return;
- }
- nativeAddLayer(layer.getNativePtr(), below);
- }
-
- @Override
- public void addLayerAbove(@NonNull Layer layer, @NonNull String above) {
- if (checkState("addLayerAbove")) {
- return;
- }
- nativeAddLayerAbove(layer.getNativePtr(), above);
- }
-
- @Override
- public void addLayerAt(@NonNull Layer layer, @IntRange(from = 0) int index) {
- if (checkState("addLayerAt")) {
- return;
- }
- nativeAddLayerAt(layer.getNativePtr(), index);
- }
-
- @Override
- public boolean removeLayer(@NonNull String layerId) {
- if (checkState("removeLayer")) {
- return false;
- }
-
- Layer layer = getLayer(layerId);
- if (layer != null) {
- return removeLayer(layer);
- }
- return false;
- }
-
-
- @Override
- public boolean removeLayer(@NonNull Layer layer) {
- if (checkState("removeLayer")) {
- return false;
- }
- return nativeRemoveLayer(layer.getNativePtr());
- }
-
- @Override
- public boolean removeLayerAt(@IntRange(from = 0) int index) {
- if (checkState("removeLayerAt")) {
- return false;
- }
- return nativeRemoveLayerAt(index);
- }
-
- @Override
- @NonNull
- public List<Source> getSources() {
- if (checkState("getSources")) {
- return new ArrayList<>();
- }
- return Arrays.asList(nativeGetSources());
- }
-
- @Override
- public Source getSource(@NonNull String sourceId) {
- if (checkState("getSource")) {
- return null;
- }
- return nativeGetSource(sourceId);
- }
-
- @Override
- public void addSource(@NonNull Source source) {
- if (checkState("addSource")) {
- return;
- }
- nativeAddSource(source, source.getNativePtr());
- }
-
- @Override
- public boolean removeSource(@NonNull String sourceId) {
- if (checkState("removeSource")) {
- return false;
- }
- Source source = getSource(sourceId);
- if (source != null) {
- return removeSource(source);
- }
- return false;
- }
-
- @Override
- public boolean removeSource(@NonNull Source source) {
- if (checkState("removeSource")) {
- return false;
- }
- return nativeRemoveSource(source, source.getNativePtr());
- }
-
- @Override
- public void addImages(@NonNull Image[] images) {
- if (checkState("addImages")) {
- return;
- }
- nativeAddImages(images);
- }
-
- @Override
- public void removeImage(String name) {
- if (checkState("removeImage")) {
- return;
- }
- nativeRemoveImage(name);
- }
-
- @Override
- public Bitmap getImage(String name) {
- if (checkState("getImage")) {
- return null;
- }
- return nativeGetImage(name);
- }
-
- // Feature querying
-
- @Override
- @NonNull
- public List<Feature> queryRenderedFeatures(@NonNull PointF coordinates,
- @Nullable String[] layerIds,
- @Nullable Expression filter) {
- if (checkState("queryRenderedFeatures")) {
- return new ArrayList<>();
- }
- Feature[] features = nativeQueryRenderedFeaturesForPoint(coordinates.x / pixelRatio,
- coordinates.y / pixelRatio, layerIds, filter != null ? filter.toArray() : null);
- return features != null ? Arrays.asList(features) : new ArrayList<Feature>();
- }
-
- @Override
- @NonNull
- public List<Feature> queryRenderedFeatures(@NonNull RectF coordinates,
- @Nullable String[] layerIds,
- @Nullable Expression filter) {
- if (checkState("queryRenderedFeatures")) {
- return new ArrayList<>();
- }
- Feature[] features = nativeQueryRenderedFeaturesForBox(
- coordinates.left / pixelRatio,
- coordinates.top / pixelRatio,
- coordinates.right / pixelRatio,
- coordinates.bottom / pixelRatio,
- layerIds,
- filter != null ? filter.toArray() : null);
- return features != null ? Arrays.asList(features) : new ArrayList<Feature>();
- }
-
- @Override
- public void setApiBaseUrl(String baseUrl) {
- if (checkState("setApiBaseUrl")) {
- return;
- }
- fileSource.setApiBaseUrl(baseUrl);
- }
-
- @Override
- public Light getLight() {
- if (checkState("getLight")) {
- return null;
- }
- return nativeGetLight();
- }
-
- @Override
- public float getPixelRatio() {
- return pixelRatio;
- }
-
- @NonNull
- @Override
- public RectF getDensityDependantRectangle(final RectF rectangle) {
- return new RectF(
- rectangle.left / pixelRatio,
- rectangle.top / pixelRatio,
- rectangle.right / pixelRatio,
- rectangle.bottom / pixelRatio
- );
- }
-
- //
- // Callbacks
- //
-
- @Keep
- private void onCameraWillChange(boolean animated) {
- if (stateCallback != null) {
- stateCallback.onCameraWillChange(animated);
- }
- }
-
- @Keep
- private void onCameraIsChanging() {
- if (stateCallback != null) {
- stateCallback.onCameraIsChanging();
- }
- }
-
- @Keep
- private void onCameraDidChange(boolean animated) {
- if (stateCallback != null) {
- stateCallback.onCameraDidChange(animated);
- }
- }
-
- @Keep
- private void onWillStartLoadingMap() {
- if (stateCallback != null) {
- stateCallback.onWillStartLoadingMap();
- }
- }
-
- @Keep
- private void onDidFinishLoadingMap() {
- if (stateCallback != null) {
- stateCallback.onDidFinishLoadingMap();
- }
- }
-
- @Keep
- private void onDidFailLoadingMap(String error) {
- if (stateCallback != null) {
- stateCallback.onDidFailLoadingMap(error);
- }
- }
-
- @Keep
- private void onWillStartRenderingFrame() {
- if (stateCallback != null) {
- stateCallback.onWillStartRenderingFrame();
- }
- }
-
- @Keep
- private void onDidFinishRenderingFrame(boolean fully) {
- if (stateCallback != null) {
- stateCallback.onDidFinishRenderingFrame(fully);
- }
- }
-
- @Keep
- private void onWillStartRenderingMap() {
- if (stateCallback != null) {
- stateCallback.onWillStartRenderingMap();
- }
- }
-
- @Keep
- private void onDidFinishRenderingMap(boolean fully) {
- if (stateCallback != null) {
- stateCallback.onDidFinishRenderingMap(fully);
- }
- }
-
- @Keep
- private void onDidBecomeIdle() {
- if (stateCallback != null) {
- stateCallback.onDidBecomeIdle();
- }
- }
-
- @Keep
- private void onDidFinishLoadingStyle() {
- if (stateCallback != null) {
- stateCallback.onDidFinishLoadingStyle();
- }
- }
-
- @Keep
- private void onSourceChanged(String sourceId) {
- if (stateCallback != null) {
- stateCallback.onSourceChanged(sourceId);
- }
- }
-
- @Keep
- private void onStyleImageMissing(String imageId) {
- if (stateCallback != null) {
- stateCallback.onStyleImageMissing(imageId);
- }
- }
-
- @Keep
- private boolean onCanRemoveUnusedStyleImage(String imageId) {
- if (stateCallback != null) {
- return stateCallback.onCanRemoveUnusedStyleImage(imageId);
- }
-
- return true;
- }
-
- @Keep
- protected void onSnapshotReady(@Nullable Bitmap mapContent) {
- if (checkState("OnSnapshotReady")) {
- return;
- }
-
- try {
- if (snapshotReadyCallback != null && mapContent != null) {
- if (viewCallback == null) {
- snapshotReadyCallback.onSnapshotReady(mapContent);
- } else {
- Bitmap viewContent = viewCallback.getViewContent();
- if (viewContent != null) {
- snapshotReadyCallback.onSnapshotReady(BitmapUtils.mergeBitmap(mapContent, viewContent));
- }
- }
- }
- } catch (Throwable err) {
- Logger.e(TAG, "Exception in onSnapshotReady", err);
- throw err;
- }
- }
-
- //
- // JNI methods
- //
-
- @Keep
- private native void nativeInitialize(NativeMapView nativeMap,
- FileSource fileSource,
- MapRenderer mapRenderer,
- float pixelRatio,
- boolean crossSourceCollisions);
-
- @Keep
- private native void nativeDestroy();
-
- @Keep
- private native void nativeResizeView(int width, int height);
-
- @Keep
- private native void nativeSetStyleUrl(String url);
-
- @NonNull
- @Keep
- private native String nativeGetStyleUrl();
-
- @Keep
- private native void nativeSetStyleJson(String newStyleJson);
-
- @NonNull
- @Keep
- private native String nativeGetStyleJson();
-
- @Keep
- private native void nativeSetLatLngBounds(LatLngBounds latLngBounds);
-
- @Keep
- private native void nativeCancelTransitions();
-
- @Keep
- private native void nativeSetGestureInProgress(boolean inProgress);
-
- @Keep
- private native void nativeMoveBy(double dx, double dy, long duration);
-
- @Keep
- private native void nativeSetLatLng(double latitude, double longitude, double[] padding, long duration);
-
- @NonNull
- @Keep
- private native LatLng nativeGetLatLng();
-
- @NonNull
- @Keep
- private native CameraPosition nativeGetCameraForLatLngBounds(
- LatLngBounds latLngBounds, double top, double left, double bottom, double right, double bearing, double tilt);
-
- @NonNull
- @Keep
- private native CameraPosition nativeGetCameraForGeometry(
- Geometry geometry, double top, double left, double bottom, double right, double bearing, double tilt);
-
- @Keep
- private native void nativeResetPosition();
-
- @Keep
- private native double nativeGetPitch();
-
- @Keep
- private native void nativeSetPitch(double pitch, long duration);
-
- @Keep
- private native void nativeSetZoom(double zoom, double cx, double cy, long duration);
-
- @Keep
- private native double nativeGetZoom();
-
- @Keep
- private native void nativeResetZoom();
-
- @Keep
- private native void nativeSetMinZoom(double zoom);
-
- @Keep
- private native double nativeGetMinZoom();
-
- @Keep
- private native void nativeSetMaxZoom(double zoom);
-
- @Keep
- private native double nativeGetMaxZoom();
-
- @Keep
- private native void nativeRotateBy(double sx, double sy, double ex, double ey, long duration);
-
- @Keep
- private native void nativeSetBearing(double degrees, long duration);
-
- @Keep
- private native void nativeSetBearingXY(double degrees, double fx, double fy, long duration);
-
- @Keep
- private native double nativeGetBearing();
-
- @Keep
- private native void nativeResetNorth();
-
- @Keep
- private native void nativeUpdateMarker(long markerId, double lat, double lon, String iconId);
-
- @NonNull
- @Keep
- private native long[] nativeAddMarkers(Marker[] markers);
-
- @NonNull
- @Keep
- private native long[] nativeAddPolylines(Polyline[] polylines);
-
- @NonNull
- @Keep
- private native long[] nativeAddPolygons(Polygon[] polygons);
-
- @Keep
- private native void nativeRemoveAnnotations(long[] id);
-
- @NonNull
- @Keep
- private native long[] nativeQueryPointAnnotations(RectF rect);
-
- @NonNull
- @Keep
- private native long[] nativeQueryShapeAnnotations(RectF rect);
-
- @Keep
- private native void nativeAddAnnotationIcon(String symbol, int width, int height, float scale, byte[] pixels);
-
- @Keep
- private native void nativeRemoveAnnotationIcon(String symbol);
-
- @Keep
- private native void nativeSetVisibleCoordinateBounds(LatLng[] coordinates, RectF padding,
- double direction, long duration);
-
- @Keep
- private native void nativeOnLowMemory();
-
- @Keep
- private native void nativeSetDebug(boolean debug);
-
- @Keep
- private native void nativeCycleDebugOptions();
-
- @Keep
- private native boolean nativeGetDebug();
-
- @Keep
- private native boolean nativeIsFullyLoaded();
-
- @Keep
- private native void nativeSetReachability(boolean status);
-
- @Keep
- private native double nativeGetMetersPerPixelAtLatitude(double lat, double zoom);
-
- @NonNull
- @Keep
- private native ProjectedMeters nativeProjectedMetersForLatLng(double latitude, double longitude);
-
- @NonNull
- @Keep
- private native LatLng nativeLatLngForProjectedMeters(double northing, double easting);
-
- @NonNull
- @Keep
- private native PointF nativePixelForLatLng(double lat, double lon);
-
- @NonNull
- @Keep
- private native LatLng nativeLatLngForPixel(float x, float y);
-
- @Keep
- private native double nativeGetTopOffsetPixelsForAnnotationSymbol(String symbolName);
-
- @Keep
- private native void nativeJumpTo(double angle, double latitude, double longitude, double pitch, double zoom,
- double[] padding);
-
- @Keep
- private native void nativeEaseTo(double angle, double latitude, double longitude,
- long duration, double pitch, double zoom, double[] padding,
- boolean easingInterpolator);
-
- @Keep
- private native void nativeFlyTo(double angle, double latitude, double longitude,
- long duration, double pitch, double zoom, double[] padding);
-
- @NonNull
- @Keep
- private native CameraPosition nativeGetCameraPosition();
-
- @Keep
- private native void nativeSetTransitionOptions(TransitionOptions transitionOptions);
-
- @NonNull
- @Keep
- private native TransitionOptions nativeGetTransitionOptions();
-
- @Keep
- private native long nativeGetTransitionDuration();
-
- @Keep
- private native void nativeSetTransitionDuration(long duration);
-
- @Keep
- private native long nativeGetTransitionDelay();
-
- @Keep
- private native void nativeSetTransitionDelay(long delay);
-
- @NonNull
- @Keep
- private native Layer[] nativeGetLayers();
-
- @NonNull
- @Keep
- private native Layer nativeGetLayer(String layerId);
-
- @Keep
- private native void nativeAddLayer(long layerPtr, String before) throws CannotAddLayerException;
-
- @Keep
- private native void nativeAddLayerAbove(long layerPtr, String above) throws CannotAddLayerException;
-
- @Keep
- private native void nativeAddLayerAt(long layerPtr, int index) throws CannotAddLayerException;
-
- @Keep
- private native boolean nativeRemoveLayer(long layerId);
-
- @Keep
- private native boolean nativeRemoveLayerAt(int index);
-
- @NonNull
- @Keep
- private native Source[] nativeGetSources();
-
- @NonNull
- @Keep
- private native Source nativeGetSource(String sourceId);
-
- @Keep
- private native void nativeAddSource(Source source, long sourcePtr) throws CannotAddSourceException;
-
- @Keep
- private native boolean nativeRemoveSource(Source source, long sourcePtr);
-
- @Keep
- private native void nativeAddImage(String name, Bitmap bitmap, float pixelRatio, boolean sdf);
-
- @Keep
- private native void nativeAddImages(Image[] images);
-
- @Keep
- private native void nativeRemoveImage(String name);
-
- @NonNull
- @Keep
- private native Bitmap nativeGetImage(String name);
-
- @Keep
- private native void nativeUpdatePolygon(long polygonId, Polygon polygon);
-
- @Keep
- private native void nativeUpdatePolyline(long polylineId, Polyline polyline);
-
- @Keep
- private native void nativeTakeSnapshot();
-
- @NonNull
- @Keep
- private native Feature[] nativeQueryRenderedFeaturesForPoint(float x, float y,
- String[] layerIds,
- Object[] filter);
-
- @NonNull
- @Keep
- private native Feature[] nativeQueryRenderedFeaturesForBox(float left, float top,
- float right, float bottom,
- String[] layerIds,
- Object[] filter);
-
- @NonNull
- @Keep
- private native Light nativeGetLight();
-
- @Keep
- private native void nativeSetPrefetchTiles(boolean enable);
-
- @Keep
- private native boolean nativeGetPrefetchTiles();
-
- @Keep
- private native void nativeSetPrefetchZoomDelta(int delta);
-
- @Keep
- private native int nativeGetPrefetchZoomDelta();
-
- @Override
- public long getNativePtr() {
- return nativePtr;
- }
-
- //
- // Snapshot
- //
-
- @Override
- public void addSnapshotCallback(@NonNull MapboxMap.SnapshotReadyCallback callback) {
- if (checkState("addSnapshotCallback")) {
- return;
- }
- snapshotReadyCallback = callback;
- nativeTakeSnapshot();
- }
-
- @Override
- public void setOnFpsChangedListener(@Nullable final MapboxMap.OnFpsChangedListener listener) {
- final Handler handler = new Handler();
- mapRenderer.queueEvent(new Runnable() {
-
- @Override
- public void run() {
- if (listener != null) {
- mapRenderer.setOnFpsChangedListener(new MapboxMap.OnFpsChangedListener() {
- @Override
- public void onFpsChanged(final double fps) {
- handler.post(new Runnable() {
-
- @Override
- public void run() {
- listener.onFpsChanged(fps);
- }
-
- });
- }
- });
- } else {
- mapRenderer.setOnFpsChangedListener(null);
- }
- }
- });
- }
-
- @Override
- public boolean isDestroyed() {
- return destroyed;
- }
-
- private double[] getAnimationPaddingAndClearCachedInsets(double[] providedPadding) {
- if (providedPadding == null) {
- providedPadding = this.edgeInsets;
- }
- this.edgeInsets = null;
- return providedPadding == null ? null :
- new double[] {
- providedPadding[1] / pixelRatio,
- providedPadding[0] / pixelRatio,
- providedPadding[3] / pixelRatio,
- providedPadding[2] / pixelRatio
- };
- }
-
- public interface ViewCallback {
- @Nullable
- Bitmap getViewContent();
- }
-
- interface StyleCallback {
- void onWillStartLoadingMap();
-
- void onDidFinishLoadingStyle();
- }
-
- interface StateCallback extends StyleCallback {
- void onCameraWillChange(boolean animated);
-
- void onCameraIsChanging();
-
- void onCameraDidChange(boolean animated);
-
- void onDidFinishLoadingMap();
-
- void onDidFailLoadingMap(String error);
-
- void onWillStartRenderingFrame();
-
- void onDidFinishRenderingFrame(boolean fully);
-
- void onWillStartRenderingMap();
-
- void onDidFinishRenderingMap(boolean fully);
-
- void onDidBecomeIdle();
-
- void onSourceChanged(String sourceId);
-
- void onStyleImageMissing(String imageId);
-
- boolean onCanRemoveUnusedStyleImage(String imageId);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/OnMapReadyCallback.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/OnMapReadyCallback.java
deleted file mode 100644
index 31b459abbd..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/OnMapReadyCallback.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.support.annotation.NonNull;
-
-/**
- * Interface definition for a callback to be invoked when the map is ready to be used.
- * <p>
- * Once an instance of this interface is set on a {@link MapFragment} or {@link MapView} object,
- * the onMapReady(MapboxMap) method is triggered when the map is ready to be used and provides an instance of
- * {@link MapboxMap}.
- * </p>
- */
-public interface OnMapReadyCallback {
-
- /**
- * Called when the map is ready to be used.
- *
- * @param mapboxMap An instance of MapboxMap associated with the {@link MapFragment} or
- * {@link MapView} that defines the callback.
- */
- void onMapReady(@NonNull MapboxMap mapboxMap);
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/PolygonContainer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/PolygonContainer.java
deleted file mode 100644
index a7e2ace061..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/PolygonContainer.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-
-import android.support.annotation.NonNull;
-import android.support.v4.util.LongSparseArray;
-
-import com.mapbox.mapboxsdk.annotations.Annotation;
-import com.mapbox.mapboxsdk.annotations.Polygon;
-import com.mapbox.mapboxsdk.annotations.PolygonOptions;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Encapsulates {@link Polygon}'s functionality.
- */
-class PolygonContainer implements Polygons {
-
- private final NativeMap nativeMap;
- private final LongSparseArray<Annotation> annotations;
-
- PolygonContainer(NativeMap nativeMap, LongSparseArray<Annotation> annotations) {
- this.nativeMap = nativeMap;
- this.annotations = annotations;
- }
-
- @Override
- public Polygon addBy(@NonNull PolygonOptions polygonOptions, @NonNull MapboxMap mapboxMap) {
- Polygon polygon = polygonOptions.getPolygon();
- if (!polygon.getPoints().isEmpty()) {
- long id = nativeMap != null ? nativeMap.addPolygon(polygon) : 0;
- polygon.setId(id);
- polygon.setMapboxMap(mapboxMap);
- annotations.put(id, polygon);
- }
- return polygon;
- }
-
- @NonNull
- @Override
- public List<Polygon> addBy(@NonNull List<PolygonOptions> polygonOptionsList, @NonNull MapboxMap mapboxMap) {
- int count = polygonOptionsList.size();
-
- Polygon polygon;
- List<Polygon> polygons = new ArrayList<>(count);
- if (nativeMap != null && count > 0) {
- for (PolygonOptions polygonOptions : polygonOptionsList) {
- polygon = polygonOptions.getPolygon();
- if (!polygon.getPoints().isEmpty()) {
- polygons.add(polygon);
- }
- }
-
- long[] ids = nativeMap.addPolygons(polygons);
- for (int i = 0; i < ids.length; i++) {
- polygon = polygons.get(i);
- polygon.setMapboxMap(mapboxMap);
- polygon.setId(ids[i]);
- annotations.put(ids[i], polygon);
- }
- }
- return polygons;
- }
-
- @Override
- public void update(@NonNull Polygon polygon) {
- nativeMap.updatePolygon(polygon);
- annotations.setValueAt(annotations.indexOfKey(polygon.getId()), polygon);
- }
-
- @NonNull
- @Override
- public List<Polygon> obtainAll() {
- List<Polygon> polygons = new ArrayList<>();
- Annotation annotation;
- for (int i = 0; i < annotations.size(); i++) {
- annotation = annotations.get(annotations.keyAt(i));
- if (annotation instanceof Polygon) {
- polygons.add((Polygon) annotation);
- }
- }
- return polygons;
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Polygons.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Polygons.java
deleted file mode 100644
index 2a0190b5ba..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Polygons.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-
-import android.support.annotation.NonNull;
-
-import com.mapbox.mapboxsdk.annotations.Polygon;
-import com.mapbox.mapboxsdk.annotations.PolygonOptions;
-
-import java.util.List;
-
-/**
- * Interface that defines convenient methods for working with a {@link Polygon}'s collection.
- */
-interface Polygons {
- Polygon addBy(@NonNull PolygonOptions polygonOptions, @NonNull MapboxMap mapboxMap);
-
- List<Polygon> addBy(@NonNull List<PolygonOptions> polygonOptionsList, @NonNull MapboxMap mapboxMap);
-
- void update(Polygon polygon);
-
- List<Polygon> obtainAll();
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/PolylineContainer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/PolylineContainer.java
deleted file mode 100644
index e11da26e08..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/PolylineContainer.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-
-import android.support.annotation.NonNull;
-import android.support.v4.util.LongSparseArray;
-
-import com.mapbox.mapboxsdk.annotations.Annotation;
-import com.mapbox.mapboxsdk.annotations.Polyline;
-import com.mapbox.mapboxsdk.annotations.PolylineOptions;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Encapsulates {@link Polyline}'s functionality.
- */
-class PolylineContainer implements Polylines {
-
- private final NativeMap nativeMap;
- private final LongSparseArray<Annotation> annotations;
-
- PolylineContainer(NativeMap nativeMap, LongSparseArray<Annotation> annotations) {
- this.nativeMap = nativeMap;
- this.annotations = annotations;
- }
-
- @Override
- public Polyline addBy(@NonNull PolylineOptions polylineOptions, @NonNull MapboxMap mapboxMap) {
- Polyline polyline = polylineOptions.getPolyline();
- if (!polyline.getPoints().isEmpty()) {
- long id = nativeMap != null ? nativeMap.addPolyline(polyline) : 0;
- polyline.setMapboxMap(mapboxMap);
- polyline.setId(id);
- annotations.put(id, polyline);
- }
- return polyline;
- }
-
- @NonNull
- @Override
- public List<Polyline> addBy(@NonNull List<PolylineOptions> polylineOptionsList, @NonNull MapboxMap mapboxMap) {
- int count = polylineOptionsList.size();
- Polyline polyline;
- List<Polyline> polylines = new ArrayList<>(count);
- if (nativeMap != null && count > 0) {
- for (PolylineOptions options : polylineOptionsList) {
- polyline = options.getPolyline();
- if (!polyline.getPoints().isEmpty()) {
- polylines.add(polyline);
- }
- }
-
- long[] ids = nativeMap.addPolylines(polylines);
- for (int i = 0; i < ids.length; i++) {
- Polyline polylineCreated = polylines.get(i);
- polylineCreated.setMapboxMap(mapboxMap);
- polylineCreated.setId(ids[i]);
- annotations.put(ids[i], polylineCreated);
- }
- }
- return polylines;
- }
-
- @Override
- public void update(@NonNull Polyline polyline) {
- nativeMap.updatePolyline(polyline);
- annotations.setValueAt(annotations.indexOfKey(polyline.getId()), polyline);
- }
-
- @NonNull
- @Override
- public List<Polyline> obtainAll() {
- List<Polyline> polylines = new ArrayList<>();
- Annotation annotation;
- for (int i = 0; i < annotations.size(); i++) {
- annotation = annotations.get(annotations.keyAt(i));
- if (annotation instanceof Polyline) {
- polylines.add((Polyline) annotation);
- }
- }
- return polylines;
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Polylines.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Polylines.java
deleted file mode 100644
index c9a865cdd0..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Polylines.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-
-import android.support.annotation.NonNull;
-
-import com.mapbox.mapboxsdk.annotations.Polyline;
-import com.mapbox.mapboxsdk.annotations.PolylineOptions;
-
-import java.util.List;
-
-/**
- * Interface that defines convenient methods for working with a {@link Polyline}'s collection.
- */
-interface Polylines {
- Polyline addBy(@NonNull PolylineOptions polylineOptions, @NonNull MapboxMap mapboxMap);
-
- List<Polyline> addBy(@NonNull List<PolylineOptions> polylineOptionsList, @NonNull MapboxMap mapboxMap);
-
- void update(Polyline polyline);
-
- List<Polyline> obtainAll();
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java
deleted file mode 100644
index 76395f9564..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java
+++ /dev/null
@@ -1,283 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.graphics.PointF;
-import android.support.annotation.FloatRange;
-import android.support.annotation.NonNull;
-
-import com.mapbox.geojson.Point;
-import com.mapbox.mapboxsdk.constants.GeometryConstants;
-import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.geometry.LatLngBounds;
-import com.mapbox.mapboxsdk.geometry.ProjectedMeters;
-import com.mapbox.mapboxsdk.geometry.VisibleRegion;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * A projection is used to translate between on screen location and geographic coordinates on
- * the surface of the Earth. Screen location is in screen pixels (not display pixels)
- * with respect to the top left corner of the map (and not necessarily of the whole screen).
- */
-public class Projection {
-
- @NonNull
- private final NativeMap nativeMapView;
- @NonNull
- private final MapView mapView;
-
- Projection(@NonNull NativeMap nativeMapView, @NonNull MapView mapView) {
- this.nativeMapView = nativeMapView;
- this.mapView = mapView;
- }
-
- void setContentPadding(int[] contentPadding) {
- double[] output = new double[contentPadding.length];
- for (int i = 0; i < contentPadding.length; i++) {
- output[i] = contentPadding[i];
- }
- nativeMapView.setContentPadding(output);
- }
-
- int[] getContentPadding() {
- double[] padding = nativeMapView.getCameraPosition().padding;
- return new int[] {(int) padding[0], (int) padding[1], (int) padding[2], (int) padding[3]};
- }
-
- /**
- * @deprecated unused
- */
- @Deprecated
- public void invalidateContentPadding() {
- }
-
- /**
- * Returns the spherical Mercator projected meters for a LatLng.
- */
- @NonNull
- public ProjectedMeters getProjectedMetersForLatLng(@NonNull LatLng latLng) {
- return nativeMapView.projectedMetersForLatLng(latLng);
- }
-
- /**
- * Returns the LatLng for a spherical Mercator projected meters.
- */
- @NonNull
- public LatLng getLatLngForProjectedMeters(@NonNull ProjectedMeters projectedMeters) {
- return nativeMapView.latLngForProjectedMeters(projectedMeters);
- }
-
- /**
- * <p>
- * Returns the distance spanned by one pixel at the specified latitude and current zoom level.
- * </p>
- * The distance between pixels decreases as the latitude approaches the poles.
- * This relationship parallels the relationship between longitudinal coordinates at different latitudes.
- *
- * @param latitude The latitude for which to return the value.
- * @return The distance measured in meters.
- */
- public double getMetersPerPixelAtLatitude(@FloatRange(from = -90, to = 90) double latitude) {
- return nativeMapView.getMetersPerPixelAtLatitude(latitude);
- }
-
- /**
- * Returns the geographic location that corresponds to a screen location.
- * The screen location is specified in screen pixels (not display pixels) relative to the
- * top left of the map (not the top left of the whole screen).
- *
- * @param point A Point on the screen in screen pixels.
- * @return The LatLng corresponding to the point on the screen, or null if the ray through
- * the given screen point does not intersect the ground plane.
- */
- @NonNull
- public LatLng fromScreenLocation(@NonNull PointF point) {
- return nativeMapView.latLngForPixel(point);
- }
-
- /**
- * Gets a projection of the viewing frustum for converting between screen coordinates and
- * geo-latitude/longitude coordinates.
- * <p>
- * This method ignores the content padding.
- *
- * @return The projection of the viewing frustum in its current state.
- */
- @NonNull
- public VisibleRegion getVisibleRegion() {
- return getVisibleRegion(true);
- }
-
- /**
- * Gets a projection of the viewing frustum for converting between screen coordinates and
- * geo-latitude/longitude coordinates.
- *
- * @param ignorePadding True if the padding should be ignored,
- * false if the returned region should be reduced by the padding.
- * @return The projection of the viewing frustum in its current state.
- */
- @NonNull
- public VisibleRegion getVisibleRegion(boolean ignorePadding) {
- float left;
- float right;
- float top;
- float bottom;
-
- if (ignorePadding) {
- left = 0;
- right = mapView.getWidth();
- top = 0;
- bottom = mapView.getHeight();
- } else {
- int[] contentPadding = getContentPadding();
- left = contentPadding[0];
- right = mapView.getWidth() - contentPadding[2];
- top = contentPadding[1];
- bottom = mapView.getHeight() - contentPadding[3];
- }
-
- LatLng center = fromScreenLocation(new PointF(left + (right - left) / 2, top + (bottom - top) / 2));
-
- LatLng topLeft = fromScreenLocation(new PointF(left, top));
- LatLng topRight = fromScreenLocation(new PointF(right, top));
- LatLng bottomRight = fromScreenLocation(new PointF(right, bottom));
- LatLng bottomLeft = fromScreenLocation(new PointF(left, bottom));
-
- List<LatLng> latLngs = new ArrayList<>();
- latLngs.add(topRight);
- latLngs.add(bottomRight);
- latLngs.add(bottomLeft);
- latLngs.add(topLeft);
-
- double maxEastLonSpan = 0;
- double maxWestLonSpan = 0;
-
- double east = 0;
- double west = 0;
- double north = GeometryConstants.MIN_LATITUDE;
- double south = GeometryConstants.MAX_LATITUDE;
-
- for (LatLng latLng : latLngs) {
- double bearing = bearing(center, latLng);
-
- if (bearing >= 0) {
- double span = getLongitudeSpan(latLng.getLongitude(), center.getLongitude());
- if (span > maxEastLonSpan) {
- maxEastLonSpan = span;
- east = latLng.getLongitude();
- }
- } else {
- double span = getLongitudeSpan(center.getLongitude(), latLng.getLongitude());
- if (span > maxWestLonSpan) {
- maxWestLonSpan = span;
- west = latLng.getLongitude();
- }
- }
-
- if (north < latLng.getLatitude()) {
- north = latLng.getLatitude();
- }
- if (south > latLng.getLatitude()) {
- south = latLng.getLatitude();
- }
- }
-
- if (east < west) {
- return new VisibleRegion(topLeft, topRight, bottomLeft, bottomRight,
- LatLngBounds.from(north, east + GeometryConstants.LONGITUDE_SPAN, south, west));
- }
- return new VisibleRegion(topLeft, topRight, bottomLeft, bottomRight,
- LatLngBounds.from(north, east, south, west));
- }
-
- /**
- * Takes two {@link Point}s and finds the geographic bearing between them.
- *
- * @param latLng1 the first point used for calculating the bearing
- * @param latLng2 the second point used for calculating the bearing
- * @return bearing in decimal degrees
- * @see <a href="http://turfjs.org/docs/#bearing">Turf Bearing documentation</a>
- */
- static double bearing(@NonNull LatLng latLng1, @NonNull LatLng latLng2) {
-
- double lon1 = degreesToRadians(latLng1.getLongitude());
- double lon2 = degreesToRadians(latLng2.getLongitude());
- double lat1 = degreesToRadians(latLng1.getLatitude());
- double lat2 = degreesToRadians(latLng2.getLatitude());
-
- double value1 = Math.sin(lon2 - lon1) * Math.cos(lat2);
- double value2 = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1)
- * Math.cos(lat2) * Math.cos(lon2 - lon1);
-
- return radiansToDegrees(Math.atan2(value1, value2));
- }
-
- /**
- * Converts an angle in degrees to radians.
- *
- * @param degrees angle between 0 and 360 degrees
- * @return angle in radians
- */
- static double degreesToRadians(double degrees) {
- double radians = degrees % 360;
- return radians * Math.PI / 180;
- }
-
- /**
- * Converts an angle in radians to degrees.
- *
- * @param radians angle in radians
- * @return degrees between 0 and 360 degrees
- */
- static double radiansToDegrees(double radians) {
- double degrees = radians % (2 * Math.PI);
- return degrees * 180 / Math.PI;
- }
-
- /**
- * Get the absolute distance, in degrees, between the west and
- * east boundaries of this LatLngBounds
- *
- * @return Span distance
- */
- static double getLongitudeSpan(double east, double west) {
- double longSpan = Math.abs(east - west);
- if (east > west) {
- return longSpan;
- }
-
- // shortest span contains antimeridian
- return GeometryConstants.LONGITUDE_SPAN - longSpan;
- }
-
- /**
- * Returns a screen location that corresponds to a geographical coordinate (LatLng).
- * The screen location is in screen pixels (not display pixels) relative to the top left
- * of the map (not of the whole screen).
- *
- * @param location A LatLng on the map to convert to a screen location.
- * @return A Point representing the screen location in screen pixels.
- */
- @NonNull
- public PointF toScreenLocation(@NonNull LatLng location) {
- return nativeMapView.pixelForLatLng(location);
- }
-
- float getHeight() {
- return mapView.getHeight();
- }
-
- float getWidth() {
- return mapView.getWidth();
- }
-
- /**
- * Calculates a zoom level based on minimum scale and current scale from MapView
- *
- * @param minScale The minimum scale to calculate the zoom level.
- * @return zoom level that fits the MapView.
- */
- public double calculateZoom(float minScale) {
- return nativeMapView.getZoom() + Math.log(minScale) / Math.log(2);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/ShapeAnnotationContainer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/ShapeAnnotationContainer.java
deleted file mode 100644
index 9c2b97b6a5..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/ShapeAnnotationContainer.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.graphics.RectF;
-import android.support.annotation.NonNull;
-import android.support.v4.util.LongSparseArray;
-
-import com.mapbox.mapboxsdk.annotations.Annotation;
-
-import java.util.ArrayList;
-import java.util.List;
-
-class ShapeAnnotationContainer implements ShapeAnnotations {
-
- private final NativeMap nativeMapView;
- private final LongSparseArray<Annotation> annotations;
-
- ShapeAnnotationContainer(NativeMap nativeMapView, LongSparseArray<Annotation> annotations) {
- this.nativeMapView = nativeMapView;
- this.annotations = annotations;
- }
-
- @NonNull
- @Override
- public List<Annotation> obtainAllIn(@NonNull RectF rectangle) {
- RectF rect = nativeMapView.getDensityDependantRectangle(rectangle);
- long[] annotationIds = nativeMapView.queryShapeAnnotations(rect);
- return getAnnotationsFromIds(annotationIds);
- }
-
- @NonNull
- private List<Annotation> getAnnotationsFromIds(long[] annotationIds) {
- List<Annotation> shapeAnnotations = new ArrayList<>();
- for (long annotationId : annotationIds) {
- Annotation annotation = annotations.get(annotationId);
- if (annotation != null) {
- shapeAnnotations.add(annotation);
- }
- }
- return shapeAnnotations;
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/ShapeAnnotations.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/ShapeAnnotations.java
deleted file mode 100644
index f9b2ca10db..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/ShapeAnnotations.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.graphics.RectF;
-
-import com.mapbox.mapboxsdk.annotations.Annotation;
-
-import java.util.List;
-
-interface ShapeAnnotations {
-
- List<Annotation> obtainAllIn(RectF rectF);
-
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Style.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Style.java
deleted file mode 100644
index b21186050b..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Style.java
+++ /dev/null
@@ -1,1150 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.graphics.Bitmap;
-import android.graphics.drawable.Drawable;
-import android.os.AsyncTask;
-import android.support.annotation.IntRange;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.annotation.StringDef;
-import android.util.DisplayMetrics;
-import android.util.Pair;
-import com.mapbox.mapboxsdk.constants.MapboxConstants;
-import com.mapbox.mapboxsdk.style.layers.Layer;
-import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
-import com.mapbox.mapboxsdk.style.light.Light;
-import com.mapbox.mapboxsdk.style.sources.Source;
-import com.mapbox.mapboxsdk.utils.BitmapUtils;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.ref.WeakReference;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * The proxy object for current map style.
- * <p>
- * To create new instances of this object, create a new instance using a {@link Builder} and load the style with
- * MapboxMap. This object is returned from {@link MapboxMap#getStyle()} once the style
- * has been loaded by underlying map.
- * </p>
- */
-@SuppressWarnings("unchecked")
-public class Style {
-
- static final String EMPTY_JSON = "{\"version\": 8,\"sources\": {},\"layers\": []}";
-
- private final NativeMap nativeMap;
- private final HashMap<String, Source> sources = new HashMap<>();
- private final HashMap<String, Layer> layers = new HashMap<>();
- private final HashMap<String, Bitmap> images = new HashMap<>();
- private final Builder builder;
- private boolean fullyLoaded;
-
- /**
- * Private constructor to build a style object.
- *
- * @param builder the builder used for creating this style
- * @param nativeMap the map object used to load this style
- */
- private Style(@NonNull Builder builder, @NonNull NativeMap nativeMap) {
- this.builder = builder;
- this.nativeMap = nativeMap;
- }
-
- /**
- * Returns the current style url.
- *
- * @return the style url
- * @deprecated use {@link #getUri()} instead
- */
- @NonNull
- @Deprecated
- public String getUrl() {
- validateState("getUrl");
- return nativeMap.getStyleUri();
- }
-
- /**
- * Returns the current style uri.
- *
- * @return the style uri
- */
- @NonNull
- public String getUri() {
- validateState("getUri");
- return nativeMap.getStyleUri();
- }
-
- /**
- * Returns the current style json.
- *
- * @return the style json
- */
- @NonNull
- public String getJson() {
- validateState("getJson");
- return nativeMap.getStyleJson();
- }
-
- //
- // Source
- //
-
- /**
- * Retrieve all the sources in the style
- *
- * @return all the sources in the current style
- */
- @NonNull
- public List<Source> getSources() {
- validateState("getSources");
- return nativeMap.getSources();
- }
-
- /**
- * Adds the source to the map. The source must be newly created and not added to the map before
- *
- * @param source the source to add
- */
- public void addSource(@NonNull Source source) {
- validateState("addSource");
- nativeMap.addSource(source);
- sources.put(source.getId(), source);
- }
-
- /**
- * Retrieve a source by id
- *
- * @param id the source's id
- * @return the source if present in the current style
- */
- @Nullable
- public Source getSource(String id) {
- validateState("getSource");
- Source source = sources.get(id);
- if (source == null) {
- source = nativeMap.getSource(id);
- }
- return source;
- }
-
- /**
- * Tries to cast the Source to T, throws ClassCastException if it's another type.
- *
- * @param sourceId the id used to look up a layer
- * @param <T> the generic type of a Source
- * @return the casted Source, null if another type
- */
- @Nullable
- public <T extends Source> T getSourceAs(@NonNull String sourceId) {
- validateState("getSourceAs");
- // noinspection unchecked
- if (sources.containsKey(sourceId)) {
- return (T) sources.get(sourceId);
- }
- return (T) nativeMap.getSource(sourceId);
- }
-
- /**
- * Removes the source from the style.
- *
- * @param sourceId the source to remove
- * @return the source handle or null if the source was not present
- */
- public boolean removeSource(@NonNull String sourceId) {
- validateState("removeSource");
- sources.remove(sourceId);
- return nativeMap.removeSource(sourceId);
- }
-
- /**
- * Removes the source, preserving the reference for re-use
- *
- * @param source the source to remove
- * @return the source
- */
- public boolean removeSource(@NonNull Source source) {
- validateState("removeSource");
- sources.remove(source.getId());
- return nativeMap.removeSource(source);
- }
-
- //
- // Layer
- //
-
- /**
- * Adds the layer to the map. The layer must be newly created and not added to the map before
- *
- * @param layer the layer to add
- */
- public void addLayer(@NonNull Layer layer) {
- validateState("addLayer");
- nativeMap.addLayer(layer);
- layers.put(layer.getId(), layer);
- }
-
- /**
- * Adds the layer to the map. The layer must be newly created and not added to the map before
- *
- * @param layer the layer to add
- * @param below the layer id to add this layer before
- */
- public void addLayerBelow(@NonNull Layer layer, @NonNull String below) {
- validateState("addLayerBelow");
- nativeMap.addLayerBelow(layer, below);
- layers.put(layer.getId(), layer);
- }
-
- /**
- * Adds the layer to the map. The layer must be newly created and not added to the map before
- *
- * @param layer the layer to add
- * @param above the layer id to add this layer above
- */
- public void addLayerAbove(@NonNull Layer layer, @NonNull String above) {
- validateState("addLayerAbove");
- nativeMap.addLayerAbove(layer, above);
- layers.put(layer.getId(), layer);
- }
-
- /**
- * Adds the layer to the map at the specified index. The layer must be newly
- * created and not added to the map before
- *
- * @param layer the layer to add
- * @param index the index to insert the layer at
- */
- public void addLayerAt(@NonNull Layer layer, @IntRange(from = 0) int index) {
- validateState("addLayerAbove");
- nativeMap.addLayerAt(layer, index);
- layers.put(layer.getId(), layer);
- }
-
- /**
- * Get the layer by id
- *
- * @param id the layer's id
- * @return the layer, if present in the style
- */
- @Nullable
- public Layer getLayer(@NonNull String id) {
- validateState("getLayer");
- Layer layer = layers.get(id);
- if (layer == null) {
- layer = nativeMap.getLayer(id);
- }
- return layer;
- }
-
- /**
- * Tries to cast the Layer to T, throws ClassCastException if it's another type.
- *
- * @param layerId the layer id used to look up a layer
- * @param <T> the generic attribute of a Layer
- * @return the casted Layer, null if another type
- */
- @Nullable
- public <T extends Layer> T getLayerAs(@NonNull String layerId) {
- validateState("getLayerAs");
- // noinspection unchecked
- return (T) nativeMap.getLayer(layerId);
- }
-
- /**
- * Retrieve all the layers in the style
- *
- * @return all the layers in the current style
- */
- @NonNull
- public List<Layer> getLayers() {
- validateState("getLayers");
- return nativeMap.getLayers();
- }
-
- /**
- * Removes the layer. Any references to the layer become invalid and should not be used anymore
- *
- * @param layerId the layer to remove
- * @return the removed layer or null if not found
- */
- public boolean removeLayer(@NonNull String layerId) {
- validateState("removeLayer");
- layers.remove(layerId);
- return nativeMap.removeLayer(layerId);
- }
-
- /**
- * Removes the layer. The reference is re-usable after this and can be re-added
- *
- * @param layer the layer to remove
- * @return the layer
- */
- public boolean removeLayer(@NonNull Layer layer) {
- validateState("removeLayer");
- layers.remove(layer.getId());
- return nativeMap.removeLayer(layer);
- }
-
- /**
- * Removes the layer. Any other references to the layer become invalid and should not be used anymore
- *
- * @param index the layer index
- * @return the removed layer or null if not found
- */
- public boolean removeLayerAt(@IntRange(from = 0) int index) {
- validateState("removeLayerAt");
- return nativeMap.removeLayerAt(index);
- }
-
- //
- // Image
- //
-
- /**
- * Adds an image to be used in the map's style
- *
- * @param name the name of the image
- * @param image the pre-multiplied Bitmap
- */
- public void addImage(@NonNull String name, @NonNull Bitmap image) {
- addImage(name, image, false);
- }
-
- /**
- * Adds an drawable to be converted into a bitmap to be used in the map's style
- *
- * @param name the name of the image
- * @param drawable the drawable instance to convert
- */
- public void addImage(@NonNull String name, @NonNull Drawable drawable) {
- Bitmap bitmap = BitmapUtils.getBitmapFromDrawable(drawable);
- if (bitmap == null) {
- throw new IllegalArgumentException("Provided drawable couldn't be converted to a Bitmap.");
- }
- addImage(name, bitmap, false);
- }
-
- /**
- * Adds an image to be used in the map's style
- *
- * @param name the name of the image
- * @param bitmap the pre-multiplied Bitmap
- * @param sdf the flag indicating image is an SDF or template image
- */
- public void addImage(@NonNull final String name, @NonNull Bitmap bitmap, boolean sdf) {
- validateState("addImage");
- nativeMap.addImages(new Image[]{toImage(new Builder.ImageWrapper(name, bitmap, sdf))});
- }
-
- /**
- * Adds an image asynchronously, to be used in the map's style.
- *
- * @param name the name of the image
- * @param image the pre-multiplied Bitmap
- */
- public void addImageAsync(@NonNull String name, @NonNull Bitmap image) {
- addImageAsync(name, image, false);
- }
-
- /**
- * Adds an drawable asynchronously, to be converted into a bitmap to be used in the map's style.
- *
- * @param name the name of the image
- * @param drawable the drawable instance to convert
- */
- public void addImageAsync(@NonNull String name, @NonNull Drawable drawable) {
- Bitmap bitmap = BitmapUtils.getBitmapFromDrawable(drawable);
- if (bitmap == null) {
- throw new IllegalArgumentException("Provided drawable couldn't be converted to a Bitmap.");
- }
- addImageAsync(name, bitmap, false);
- }
-
- /**
- * Adds an image asynchronously, to be used in the map's style.
- *
- * @param name the name of the image
- * @param bitmap the pre-multiplied Bitmap
- * @param sdf the flag indicating image is an SDF or template image
- */
- public void addImageAsync(@NonNull final String name, @NonNull Bitmap bitmap, boolean sdf) {
- validateState("addImage");
- new BitmapImageConversionTask(nativeMap).execute(new Builder.ImageWrapper(name, bitmap, sdf));
- }
-
- /**
- * Adds images to be used in the map's style.
- *
- * @param images the map of images to add
- */
- public void addImages(@NonNull HashMap<String, Bitmap> images) {
- addImages(images, false);
- }
-
- /**
- * Adds images to be used in the map's style.
- *
- * @param images the map of images to add
- * @param sdf the flag indicating image is an SDF or template image
- */
- public void addImages(@NonNull HashMap<String, Bitmap> images, boolean sdf) {
- validateState("addImage");
- Image[] convertedImages = new Image[images.size()];
- int index = 0;
- for (Builder.ImageWrapper imageWrapper : Builder.ImageWrapper.convertToImageArray(images, sdf)) {
- convertedImages[index] = toImage(imageWrapper);
- index++;
- }
-
- nativeMap.addImages(convertedImages);
- }
-
- /**
- * Adds images asynchronously, to be used in the map's style.
- *
- * @param images the map of images to add
- */
- public void addImagesAsync(@NonNull HashMap<String, Bitmap> images) {
- addImagesAsync(images, false);
- }
-
- /**
- * Adds images asynchronously, to be used in the map's style.
- *
- * @param images the map of images to add
- * @param sdf the flag indicating image is an SDF or template image
- */
- public void addImagesAsync(@NonNull HashMap<String, Bitmap> images, boolean sdf) {
- validateState("addImages");
- new BitmapImageConversionTask(nativeMap).execute(Builder.ImageWrapper.convertToImageArray(images, sdf));
- }
-
- /**
- * Removes an image from the map's style.
- *
- * @param name the name of the image to remove
- */
- public void removeImage(@NonNull String name) {
- validateState("removeImage");
- nativeMap.removeImage(name);
- }
-
- /**
- * Get an image from the map's style using an id.
- *
- * @param id the id of the image
- * @return the image bitmap
- */
- @Nullable
- public Bitmap getImage(@NonNull String id) {
- validateState("getImage");
- return nativeMap.getImage(id);
- }
-
- //
- // Transition
- //
-
- /**
- * <p>
- * Set the transition options for style changes.
- * </p>
- * If not set, any changes take effect without animation, besides symbols,
- * which will fade in/out with a default duration after symbol collision detection.
- * <p>
- * To disable symbols fade in/out animation,
- * pass transition options with {@link TransitionOptions#enablePlacementTransitions} equal to false.
- * <p>
- * Both {@link TransitionOptions#duration} and {@link TransitionOptions#delay}
- * will also change the behavior of the symbols fade in/out animation if the placement transition is enabled.
- *
- * @param transitionOptions the transition options
- */
- public void setTransition(@NonNull TransitionOptions transitionOptions) {
- validateState("setTransition");
- nativeMap.setTransitionOptions(transitionOptions);
- }
-
- /**
- * <p>
- * Get the transition options for style changes.
- * </p>
- * By default, any changes take effect without animation, besides symbols,
- * which will fade in/out with a default duration after symbol collision detection.
- * <p>
- * To disable symbols fade in/out animation,
- * pass transition options with {@link TransitionOptions#enablePlacementTransitions} equal to false
- * into {@link #setTransition(TransitionOptions)}.
- * <p>
- * Both {@link TransitionOptions#duration} and {@link TransitionOptions#delay}
- * will also change the behavior of the symbols fade in/out animation if the placement transition is enabled.
- *
- * @return TransitionOptions the transition options
- */
- @NonNull
- public TransitionOptions getTransition() {
- validateState("getTransition");
- return nativeMap.getTransitionOptions();
- }
-
- //
- // Light
- //
-
- /**
- * Get the light source used to change lighting conditions on extruded fill layers.
- *
- * @return the global light source
- */
- @Nullable
- public Light getLight() {
- validateState("getLight");
- return nativeMap.getLight();
- }
-
- //
- // State
- //
-
- /**
- * Called when the underlying map will start loading a new style or the map is destroyed.
- * This method will clean up this style by setting the java sources and layers
- * in a detached state and removing them from core.
- */
- void clear() {
- fullyLoaded = false;
- for (Layer layer : layers.values()) {
- if (layer != null) {
- layer.setDetached();
- }
- }
-
- for (Source source : sources.values()) {
- if (source != null) {
- source.setDetached();
- }
- }
-
- for (Map.Entry<String, Bitmap> bitmapEntry : images.entrySet()) {
- nativeMap.removeImage(bitmapEntry.getKey());
- bitmapEntry.getValue().recycle();
- }
-
- sources.clear();
- layers.clear();
- images.clear();
- }
-
- /**
- * Called when the underlying map has finished loading this style.
- * This method will add all components added to the builder that were defined with the 'with' prefix.
- */
- void onDidFinishLoadingStyle() {
- if (!fullyLoaded) {
- fullyLoaded = true;
- for (Source source : builder.sources) {
- addSource(source);
- }
-
- for (Builder.LayerWrapper layerWrapper : builder.layers) {
- if (layerWrapper instanceof Builder.LayerAtWrapper) {
- addLayerAt(layerWrapper.layer, ((Builder.LayerAtWrapper) layerWrapper).index);
- } else if (layerWrapper instanceof Builder.LayerAboveWrapper) {
- addLayerAbove(layerWrapper.layer, ((Builder.LayerAboveWrapper) layerWrapper).aboveLayer);
- } else if (layerWrapper instanceof Builder.LayerBelowWrapper) {
- addLayerBelow(layerWrapper.layer, ((Builder.LayerBelowWrapper) layerWrapper).belowLayer);
- } else {
- // just add layer to map, but below annotations
- addLayerBelow(layerWrapper.layer, MapboxConstants.LAYER_ID_ANNOTATIONS);
- }
- }
-
- for (Builder.ImageWrapper image : builder.images) {
- addImage(image.id, image.bitmap, image.sdf);
- }
-
- if (builder.transitionOptions != null) {
- setTransition(builder.transitionOptions);
- }
- }
- }
-
- /**
- * Returns true if the style is fully loaded. Returns false if style hasn't been fully loaded or a new style is
- * underway of being loaded.
- *
- * @return True if fully loaded, false otherwise
- */
- public boolean isFullyLoaded() {
- return fullyLoaded;
- }
-
- /**
- * Validates the style state, throw an IllegalArgumentException on invalid state.
- *
- * @param methodCall the calling method name
- */
- private void validateState(String methodCall) {
- if (!fullyLoaded) {
- throw new IllegalStateException(
- String.format("Calling %s when a newer style is loading/has loaded.", methodCall)
- );
- }
- }
-
- //
- // Builder
- //
-
- /**
- * Builder for composing a style object.
- */
- public static class Builder {
-
- private final List<Source> sources = new ArrayList<>();
- private final List<LayerWrapper> layers = new ArrayList<>();
- private final List<ImageWrapper> images = new ArrayList<>();
-
- private TransitionOptions transitionOptions;
- private String styleUri;
- private String styleJson;
-
- /**
- * <p>
- * Will loads a new map style asynchronous from the specified URL.
- * </p>
- * {@code url} can take the following forms:
- * <ul>
- * <li>{@code Style#StyleUrl}: load one of the bundled styles in {@link Style}.</li>
- * <li>{@code mapbox://styles/<user>/<style>}:
- * loads the style from a <a href="https://www.mapbox.com/account/">Mapbox account.</a>
- * {@code user} is your username. {@code style} is the ID of your custom
- * style created in <a href="https://www.mapbox.com/studio">Mapbox Studio</a>.</li>
- * <li>{@code http://...} or {@code https://...}:
- * loads the style over the Internet from any web server.</li>
- * <li>{@code asset://...}:
- * loads the style from the APK {@code assets/} directory.
- * This is used to load a style bundled with your app.</li>
- * <li>{@code file://...}:
- * loads the style from a file path. This is used to load a style from disk.
- * </li>
- * </li>
- * <li>{@code null}: loads the default {@link Style#MAPBOX_STREETS} style.</li>
- * </ul>
- * <p>
- * This method is asynchronous and will return before the style finishes loading.
- * If you wish to wait for the map to finish loading, listen to the {@link MapView.OnDidFinishLoadingStyleListener}
- * callback or provide an {@link OnStyleLoaded} callback when setting the style on MapboxMap.
- * </p>
- * If the style fails to load or an invalid style URL is set, the map view will become blank.
- * An error message will be logged in the Android logcat and {@link MapView.OnDidFailLoadingMapListener} callback
- * will be triggered.
- *
- * @param url The URL of the map style
- * @return this
- * @see Style
- * @deprecated use {@link #fromUri(String)} instead
- */
- @Deprecated
- @NonNull
- public Builder fromUrl(@NonNull String url) {
- this.styleUri = url;
- return this;
- }
-
- /**
- * <p>
- * Will loads a new map style asynchronous from the specified URI.
- * </p>
- * {@code uri} can take the following forms:
- * <ul>
- * <li>{@code Style#StyleUrl}: load one of the bundled styles in {@link Style}.</li>
- * <li>{@code mapbox://styles/<user>/<style>}:
- * loads the style from a <a href="https://www.mapbox.com/account/">Mapbox account.</a>
- * {@code user} is your username. {@code style} is the ID of your custom
- * style created in <a href="https://www.mapbox.com/studio">Mapbox Studio</a>.</li>
- * <li>{@code http://...} or {@code https://...}:
- * loads the style over the Internet from any web server.</li>
- * <li>{@code asset://...}:
- * loads the style from the APK {@code assets/} directory.
- * This is used to load a style bundled with your app.</li>
- * <li>{@code file://...}:
- * loads the style from a file path. This is used to load a style from disk.
- * </li>
- * </li>
- * <li>{@code null}: loads the default {@link Style#MAPBOX_STREETS} style.</li>
- * </ul>
- * <p>
- * This method is asynchronous and will return before the style finishes loading.
- * If you wish to wait for the map to finish loading, listen to the {@link MapView.OnDidFinishLoadingStyleListener}
- * callback or use {@link MapboxMap#setStyle(String, OnStyleLoaded)} instead.
- * </p>
- * If the style fails to load or an invalid style URI is set, the map view will become blank.
- * An error message will be logged in the Android logcat and {@link MapView.OnDidFailLoadingMapListener} callback
- * will be triggered.
- *
- * @param uri The URI of the map style
- * @return this
- * @see Style
- */
- @NonNull
- public Builder fromUri(@NonNull String uri) {
- this.styleUri = uri;
- return this;
- }
-
- /**
- * Will load a new map style from a json string.
- * <p>
- * If the style fails to load or an invalid style URI is set, the map view will become blank.
- * An error message will be logged in the Android logcat and {@link MapView.OnDidFailLoadingMapListener} callback
- * will be triggered.
- * </p>
- *
- * @return this
- */
- @NonNull
- public Builder fromJson(@NonNull String styleJson) {
- this.styleJson = styleJson;
- return this;
- }
-
- /**
- * Will add the source when map style has loaded.
- *
- * @param source the source to add
- * @return this
- */
- @NonNull
- public Builder withSource(@NonNull Source source) {
- sources.add(source);
- return this;
- }
-
- /**
- * Will add the sources when map style has loaded.
- *
- * @param sources the sources to add
- * @return this
- */
- @NonNull
- public Builder withSources(@NonNull Source... sources) {
- this.sources.addAll(Arrays.asList(sources));
- return this;
- }
-
- /**
- * Will add the layer when the style has loaded.
- *
- * @param layer the layer to be added
- * @return this
- */
- @NonNull
- public Builder withLayer(@NonNull Layer layer) {
- layers.add(new LayerWrapper(layer));
- return this;
- }
-
- /**
- * Will add the layers when the style has loaded.
- *
- * @param layers the layers to be added
- * @return this
- */
- @NonNull
- public Builder withLayers(@NonNull Layer... layers) {
- for (Layer layer : layers) {
- this.layers.add(new LayerWrapper(layer));
- }
- return this;
- }
-
- /**
- * Will add the layer when the style has loaded at a specified index.
- *
- * @param layer the layer to be added
- * @return this
- */
- @NonNull
- public Builder withLayerAt(@NonNull Layer layer, int index) {
- layers.add(new LayerAtWrapper(layer, index));
- return this;
- }
-
- /**
- * Will add the layer when the style has loaded above a specified layer id.
- *
- * @param layer the layer to be added
- * @return this
- */
- @NonNull
- public Builder withLayerAbove(@NonNull Layer layer, @NonNull String aboveLayerId) {
- layers.add(new LayerAboveWrapper(layer, aboveLayerId));
- return this;
- }
-
- /**
- * Will add the layer when the style has loaded below a specified layer id.
- *
- * @param layer the layer to be added
- * @return this
- */
- @NonNull
- public Builder withLayerBelow(@NonNull Layer layer, @NonNull String belowLayerId) {
- layers.add(new LayerBelowWrapper(layer, belowLayerId));
- return this;
- }
-
- /**
- * Will add the transition when the map style has loaded.
- *
- * @param transition the transition to be added
- * @return this
- */
- @NonNull
- public Builder withTransition(@NonNull TransitionOptions transition) {
- this.transitionOptions = transition;
- return this;
- }
-
- /**
- * Will add the drawable as image when the map style has loaded.
- *
- * @param id the id for the image
- * @param drawable the drawable to be converted and added
- * @return this
- */
- @NonNull
- public Builder withImage(@NonNull String id, @NonNull Drawable drawable) {
- Bitmap bitmap = BitmapUtils.getBitmapFromDrawable(drawable);
- if (bitmap == null) {
- throw new IllegalArgumentException("Provided drawable couldn't be converted to a Bitmap.");
- }
- return this.withImage(id, bitmap, false);
- }
-
- /**
- * Will add the drawables as images when the map style has loaded.
- *
- * @param values pairs, where first is the id for te image and second is the drawable
- * @return this
- */
- @NonNull
- public Builder withDrawableImages(@NonNull Pair<String, Drawable>... values) {
- return this.withDrawableImages(false, values);
- }
-
- /**
- * Will add the image when the map style has loaded.
- *
- * @param id the id for the image
- * @param image the image to be added
- * @return this
- */
- @NonNull
- public Builder withImage(@NonNull String id, @NonNull Bitmap image) {
- return this.withImage(id, image, false);
- }
-
- /**
- * Will add the images when the map style has loaded.
- *
- * @param values pairs, where first is the id for te image and second is the bitmap
- * @return this
- */
- @NonNull
- public Builder withBitmapImages(@NonNull Pair<String, Bitmap>... values) {
- for (Pair<String, Bitmap> value : values) {
- this.withImage(value.first, value.second, false);
- }
- return this;
- }
-
- /**
- * Will add the drawable as image when the map style has loaded.
- *
- * @param id the id for the image
- * @param drawable the drawable to be converted and added
- * @param sdf the flag indicating image is an SDF or template image
- * @return this
- */
- @NonNull
- public Builder withImage(@NonNull String id, @NonNull Drawable drawable, boolean sdf) {
- Bitmap bitmap = BitmapUtils.getBitmapFromDrawable(drawable);
- if (bitmap == null) {
- throw new IllegalArgumentException("Provided drawable couldn't be converted to a Bitmap.");
- }
- return this.withImage(id, bitmap, sdf);
- }
-
- /**
- * Will add the drawables as images when the map style has loaded.
- *
- * @param sdf the flag indicating image is an SDF or template image
- * @param values pairs, where first is the id for te image and second is the drawable
- * @return this
- */
- @NonNull
- public Builder withDrawableImages(boolean sdf, @NonNull Pair<String, Drawable>... values) {
- for (Pair<String, Drawable> value : values) {
- Bitmap bitmap = BitmapUtils.getBitmapFromDrawable(value.second);
- if (bitmap == null) {
- throw new IllegalArgumentException("Provided drawable couldn't be converted to a Bitmap.");
- }
- this.withImage(value.first, bitmap, sdf);
- }
- return this;
- }
-
- /**
- * Will add the image when the map style has loaded.
- *
- * @param id the id for the image
- * @param image the image to be added
- * @param sdf the flag indicating image is an SDF or template image
- * @return this
- */
- @NonNull
- public Builder withImage(@NonNull String id, @NonNull Bitmap image, boolean sdf) {
- images.add(new ImageWrapper(id, image, sdf));
- return this;
- }
-
- /**
- * Will add the images when the map style has loaded.
- *
- * @param sdf the flag indicating image is an SDF or template image
- * @param values pairs, where first is the id for te image and second is the bitmap
- * @return this
- */
- @NonNull
- public Builder withBitmapImages(boolean sdf, @NonNull Pair<String, Bitmap>... values) {
- for (Pair<String, Bitmap> value : values) {
- this.withImage(value.first, value.second, sdf);
- }
- return this;
- }
-
- String getUri() {
- return styleUri;
- }
-
- String getJson() {
- return styleJson;
- }
-
- List<Source> getSources() {
- return sources;
- }
-
- List<LayerWrapper> getLayers() {
- return layers;
- }
-
- List<ImageWrapper> getImages() {
- return images;
- }
-
- TransitionOptions getTransitionOptions() {
- return transitionOptions;
- }
-
- /**
- * Build the composed style.
- */
- Style build(@NonNull NativeMap nativeMap) {
- return new Style(this, nativeMap);
- }
-
- static class ImageWrapper {
- Bitmap bitmap;
- String id;
- boolean sdf;
-
- ImageWrapper(String id, Bitmap bitmap, boolean sdf) {
- this.id = id;
- this.bitmap = bitmap;
- this.sdf = sdf;
- }
-
- static ImageWrapper[] convertToImageArray(HashMap<String, Bitmap> bitmapHashMap, boolean sdf) {
- ImageWrapper[] images = new ImageWrapper[bitmapHashMap.size()];
- List<String> keyList = new ArrayList<>(bitmapHashMap.keySet());
- for (int i = 0; i < bitmapHashMap.size(); i++) {
- String id = keyList.get(i);
- images[i] = new ImageWrapper(id, bitmapHashMap.get(id), sdf);
- }
- return images;
- }
- }
-
- class LayerWrapper {
- Layer layer;
-
- LayerWrapper(Layer layer) {
- this.layer = layer;
- }
- }
-
- class LayerAboveWrapper extends LayerWrapper {
- String aboveLayer;
-
- LayerAboveWrapper(Layer layer, String aboveLayer) {
- super(layer);
- this.aboveLayer = aboveLayer;
- }
- }
-
- class LayerBelowWrapper extends LayerWrapper {
- String belowLayer;
-
- LayerBelowWrapper(Layer layer, String belowLayer) {
- super(layer);
- this.belowLayer = belowLayer;
- }
- }
-
- class LayerAtWrapper extends LayerWrapper {
- int index;
-
- LayerAtWrapper(Layer layer, int index) {
- super(layer);
- this.index = index;
- }
- }
- }
-
- private static Image toImage(Builder.ImageWrapper imageWrapper) {
- Bitmap bitmap = imageWrapper.bitmap;
- if (bitmap.getConfig() != Bitmap.Config.ARGB_8888) {
- bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, false);
- }
-
- ByteBuffer buffer = ByteBuffer.allocate(bitmap.getByteCount());
- bitmap.copyPixelsToBuffer(buffer);
- float pixelRatio = (float) bitmap.getDensity() / DisplayMetrics.DENSITY_DEFAULT;
-
- return new Image(buffer.array(), pixelRatio, imageWrapper.id,
- bitmap.getWidth(), bitmap.getHeight(), imageWrapper.sdf
- );
- }
-
- private static class BitmapImageConversionTask extends AsyncTask<Builder.ImageWrapper, Void, Image[]> {
-
- private WeakReference<NativeMap> nativeMap;
-
- BitmapImageConversionTask(NativeMap nativeMap) {
- this.nativeMap = new WeakReference<>(nativeMap);
- }
-
- @NonNull
- @Override
- protected Image[] doInBackground(Builder.ImageWrapper... params) {
- List<Image> images = new ArrayList<>();
- for (Builder.ImageWrapper param : params) {
- images.add(toImage(param));
- }
- return images.toArray(new Image[images.size()]);
- }
-
- @Override
- protected void onPostExecute(@NonNull Image[] images) {
- super.onPostExecute(images);
- NativeMap nativeMap = this.nativeMap.get();
- if (nativeMap != null && !nativeMap.isDestroyed()) {
- nativeMap.addImages(images);
- }
- }
- }
-
- /**
- * Callback to be invoked when a style has finished loading.
- */
- public interface OnStyleLoaded {
- /**
- * Invoked when a style has finished loading.
- *
- * @param style the style that has finished loading
- */
- void onStyleLoaded(@NonNull Style style);
- }
-
- //
- // Style URL constants
- //
-
- /**
- * Indicates the parameter accepts one of the values from Style. Using one of these
- * constants means your map style will always use the latest version and may change as we
- * improve the style
- */
- @StringDef( {MAPBOX_STREETS, OUTDOORS, LIGHT, DARK, SATELLITE, SATELLITE_STREETS, TRAFFIC_DAY, TRAFFIC_NIGHT})
- @Retention(RetentionPolicy.SOURCE)
- public @interface StyleUrl {
- }
-
- // IMPORTANT: If you change any of these you also need to edit them in strings.xml
-
- /**
- * Mapbox Streets: A complete basemap, perfect for incorporating your own data. Using this
- * constant means your map style will always use the latest version and may change as we
- * improve the style.
- */
- public static final String MAPBOX_STREETS = "mapbox://styles/mapbox/streets-v11";
-
- /**
- * Outdoors: A general-purpose style tailored to outdoor activities. Using this constant means
- * your map style will always use the latest version and may change as we improve the style.
- */
- public static final String OUTDOORS = "mapbox://styles/mapbox/outdoors-v11";
-
- /**
- * Light: Subtle light backdrop for data visualizations. Using this constant means your map
- * style will always use the latest version and may change as we improve the style.
- */
- public static final String LIGHT = "mapbox://styles/mapbox/light-v10";
-
- /**
- * Dark: Subtle dark backdrop for data visualizations. Using this constant means your map style
- * will always use the latest version and may change as we improve the style.
- */
- public static final String DARK = "mapbox://styles/mapbox/dark-v10";
-
- /**
- * Satellite: A beautiful global satellite and aerial imagery layer. Using this constant means
- * your map style will always use the latest version and may change as we improve the style.
- */
- public static final String SATELLITE = "mapbox://styles/mapbox/satellite-v9";
-
- /**
- * Satellite Streets: Global satellite and aerial imagery with unobtrusive labels. Using this
- * constant means your map style will always use the latest version and may change as we
- * improve the style.
- */
- public static final String SATELLITE_STREETS = "mapbox://styles/mapbox/satellite-streets-v11";
-
- /**
- * Traffic Day: Color-coded roads based on live traffic congestion data. Traffic data is currently
- * available in
- * <a href="https://www.mapbox.com/help/how-directions-work/#traffic-data">these select
- * countries</a>. Using this constant means your map style will always use the latest version and
- * may change as we improve the style.
- */
- public static final String TRAFFIC_DAY = "mapbox://styles/mapbox/traffic-day-v2";
-
- /**
- * Traffic Night: Color-coded roads based on live traffic congestion data, designed to maximize
- * legibility in low-light situations. Traffic data is currently available in
- * <a href="https://www.mapbox.com/help/how-directions-work/#traffic-data">these select
- * countries</a>. Using this constant means your map style will always use the latest version and
- * may change as we improve the style.
- */
- public static final String TRAFFIC_NIGHT = "mapbox://styles/mapbox/traffic-night-v2";
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/SupportMapFragment.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/SupportMapFragment.java
deleted file mode 100644
index 011a0bdaa2..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/SupportMapFragment.java
+++ /dev/null
@@ -1,219 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.content.Context;
-import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v4.app.Fragment;
-import android.util.AttributeSet;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import com.mapbox.mapboxsdk.utils.MapFragmentUtils;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Support Fragment wrapper around a map view.
- * <p>
- * A Map component in an app. This fragment is the simplest way to place a map in an application.
- * It's a wrapper around a view of a map to automatically handle the necessary life cycle needs.
- * Being a fragment, this component can be added to an activity's layout or can dynamically be added
- * using a FragmentManager.
- * </p>
- * <p>
- * To get a reference to the MapView, use {@link #getMapAsync(OnMapReadyCallback)}}
- * </p>
- *
- * @see #getMapAsync(OnMapReadyCallback)
- */
-public class SupportMapFragment extends Fragment implements OnMapReadyCallback {
-
- private final List<OnMapReadyCallback> mapReadyCallbackList = new ArrayList<>();
- private MapFragment.OnMapViewReadyCallback mapViewReadyCallback;
- private MapboxMap mapboxMap;
- private MapView map;
-
- /**
- * Creates a default MapFragment instance
- *
- * @return MapFragment created
- */
- public static SupportMapFragment newInstance() {
- return new SupportMapFragment();
- }
-
- /**
- * Creates a MapFragment instance
- *
- * @param mapboxMapOptions The configuration options to be used.
- * @return MapFragment created.
- */
- @NonNull
- public static SupportMapFragment newInstance(@Nullable MapboxMapOptions mapboxMapOptions) {
- SupportMapFragment mapFragment = new SupportMapFragment();
- mapFragment.setArguments(MapFragmentUtils.createFragmentArgs(mapboxMapOptions));
- return mapFragment;
- }
-
- /**
- * Called when the context attaches to this fragment.
- *
- * @param context the context attaching
- */
- @Override
- public void onAttach(Context context) {
- super.onAttach(context);
- if (context instanceof MapFragment.OnMapViewReadyCallback) {
- mapViewReadyCallback = (MapFragment.OnMapViewReadyCallback) context;
- }
- }
-
- /**
- * Called when this fragment is inflated, parses XML tag attributes.
- *
- * @param context The context inflating this fragment.
- * @param attrs The XML tag attributes.
- * @param savedInstanceState The saved instance state for the map fragment.
- */
- @Override
- public void onInflate(@NonNull Context context, AttributeSet attrs, Bundle savedInstanceState) {
- super.onInflate(context, attrs, savedInstanceState);
- setArguments(MapFragmentUtils.createFragmentArgs(MapboxMapOptions.createFromAttributes(context, attrs)));
- }
-
- /**
- * Creates the fragment view hierarchy.
- *
- * @param inflater Inflater used to inflate content.
- * @param container The parent layout for the map fragment.
- * @param savedInstanceState The saved instance state for the map fragment.
- * @return The view created
- */
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- super.onCreateView(inflater, container, savedInstanceState);
- Context context = inflater.getContext();
- map = new MapView(context, MapFragmentUtils.resolveArgs(context, getArguments()));
- return map;
- }
-
- /**
- * Called when the fragment view hierarchy is created.
- *
- * @param view The content view of the fragment
- * @param savedInstanceState THe saved instance state of the framgnt
- */
- @Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
- map.onCreate(savedInstanceState);
- map.getMapAsync(this);
-
- // notify listeners about MapView creation
- if (mapViewReadyCallback != null) {
- mapViewReadyCallback.onMapViewReady(map);
- }
- }
-
- @Override
- public void onMapReady(@NonNull MapboxMap mapboxMap) {
- this.mapboxMap = mapboxMap;
- for (OnMapReadyCallback onMapReadyCallback : mapReadyCallbackList) {
- onMapReadyCallback.onMapReady(mapboxMap);
- }
- }
-
- /**
- * Called when the fragment is visible for the users.
- */
- @Override
- public void onStart() {
- super.onStart();
- map.onStart();
- }
-
- /**
- * Called when the fragment is ready to be interacted with.
- */
- @Override
- public void onResume() {
- super.onResume();
- map.onResume();
- }
-
- /**
- * Called when the fragment is pausing.
- */
- @Override
- public void onPause() {
- super.onPause();
- map.onPause();
- }
-
- /**
- * Called when the fragment state needs to be saved.
- *
- * @param outState The saved state
- */
- @Override
- public void onSaveInstanceState(@NonNull Bundle outState) {
- super.onSaveInstanceState(outState);
- if (map != null) {
- map.onSaveInstanceState(outState);
- }
- }
-
- /**
- * Called when the fragment is no longer visible for the user.
- */
- @Override
- public void onStop() {
- super.onStop();
- map.onStop();
- }
-
- /**
- * Called when the fragment receives onLowMemory call from the hosting Activity.
- */
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- if (map != null) {
- map.onLowMemory();
- }
- }
-
- /**
- * Called when the fragment is view hierarchy is being destroyed.
- */
- @Override
- public void onDestroyView() {
- super.onDestroyView();
- map.onDestroy();
- }
-
- /**
- * Called when the fragment is destroyed.
- */
- @Override
- public void onDestroy() {
- super.onDestroy();
- mapReadyCallbackList.clear();
- }
-
- /**
- * Sets a callback object which will be triggered when the MapboxMap instance is ready to be used.
- *
- * @param onMapReadyCallback The callback to be invoked.
- */
- public void getMapAsync(@NonNull final OnMapReadyCallback onMapReadyCallback) {
- if (mapboxMap == null) {
- mapReadyCallbackList.add(onMapReadyCallback);
- } else {
- onMapReadyCallback.onMapReady(mapboxMap);
- }
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TelemetryDefinition.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TelemetryDefinition.java
deleted file mode 100644
index 863d821a12..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TelemetryDefinition.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.os.Bundle;
-
-import com.mapbox.mapboxsdk.offline.OfflineRegionDefinition;
-
-/**
- * Definition of TelemetryImpl collection.
- * Use{@link TelemetryDefinition} for posting the event.
- */
-public interface TelemetryDefinition {
-
- /**
- * Register the app user turnstile event
- */
- void onAppUserTurnstileEvent();
-
- /**
- * Register an end-user gesture interaction event.
- *
- * @param eventType type of gesture event occurred
- * @param latitude the latitude value of the gesture focal point
- * @param longitude the longitude value of the gesture focal point
- * @param zoom current zoom of the map
- * @deprecated since 7.5.0, this event is no longer supported
- */
- @Deprecated
- void onGestureInteraction(String eventType, double latitude, double longitude, double zoom);
-
- /**
- * Set the end-user selected state to participate or opt-out in telemetry collection.
- */
- void setUserTelemetryRequestState(boolean enabled);
-
- /**
- * Disables a started telemetry service for this session only.
- */
- void disableTelemetrySession();
-
- /**
- * Set the end-user selected state to participate or opt-out in telemetry collection.
- */
- void setDebugLoggingEnabled(boolean debugLoggingEnabled);
-
- /**
- * Set the telemetry rotation session id interval
- *
- * @param interval the selected session interval
- * @return true if rotation session id was updated
- */
- boolean setSessionIdRotationInterval(int interval);
-
- /**
- * Register an end-user offline download event.
- *
- * @param offlineDefinition the offline region definition
- */
- void onCreateOfflineRegion(OfflineRegionDefinition offlineDefinition);
-
- /**
- * Register a performance event.
- *
- * @param data performance event data
- */
- void onPerformanceEvent(Bundle data);
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java
deleted file mode 100644
index f785aacf3c..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java
+++ /dev/null
@@ -1,341 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.graphics.PointF;
-import android.os.Handler;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.annotation.UiThread;
-
-import com.mapbox.mapboxsdk.camera.CameraPosition;
-import com.mapbox.mapboxsdk.camera.CameraUpdate;
-import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
-import com.mapbox.mapboxsdk.constants.MapboxConstants;
-import com.mapbox.mapboxsdk.geometry.LatLng;
-import com.mapbox.mapboxsdk.log.Logger;
-
-import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener;
-
-/**
- * Internal use.
- * <p>
- * Resembles the current Map transformation.
- * </p>
- * <p>
- * Responsible for synchronising {@link CameraPosition} state and notifying camera change listeners.
- * </p>
- */
-public final class Transform implements MapView.OnCameraDidChangeListener {
-
- private static final String TAG = "Mbgl-Transform";
-
- private final NativeMap nativeMap;
- private final MapView mapView;
- private final Handler handler = new Handler();
-
- @Nullable
- private CameraPosition cameraPosition;
- @Nullable
- private MapboxMap.CancelableCallback cameraCancelableCallback;
- private CameraChangeDispatcher cameraChangeDispatcher;
-
- private final MapView.OnCameraDidChangeListener moveByChangeListener = new MapView.OnCameraDidChangeListener() {
- @Override
- public void onCameraDidChange(boolean animated) {
- if (animated) {
- cameraChangeDispatcher.onCameraIdle();
- mapView.removeOnCameraDidChangeListener(this);
- }
- }
- };
-
- Transform(MapView mapView, NativeMap nativeMap, CameraChangeDispatcher cameraChangeDispatcher) {
- this.mapView = mapView;
- this.nativeMap = nativeMap;
- this.cameraChangeDispatcher = cameraChangeDispatcher;
- }
-
- void initialise(@NonNull MapboxMap mapboxMap, @NonNull MapboxMapOptions options) {
- CameraPosition position = options.getCamera();
- if (position != null && !position.equals(CameraPosition.DEFAULT)) {
- moveCamera(mapboxMap, CameraUpdateFactory.newCameraPosition(position), null);
- }
- setMinZoom(options.getMinZoomPreference());
- setMaxZoom(options.getMaxZoomPreference());
- }
-
- //
- // Camera API
- //
-
- @Nullable
- @UiThread
- public final CameraPosition getCameraPosition() {
- if (cameraPosition == null) {
- cameraPosition = invalidateCameraPosition();
- }
- return cameraPosition;
- }
-
- @Override
- public void onCameraDidChange(boolean animated) {
- if (animated) {
- invalidateCameraPosition();
- if (cameraCancelableCallback != null) {
- final MapboxMap.CancelableCallback callback = cameraCancelableCallback;
-
- // nullification has to happen before Handler#post, see https://github.com/robolectric/robolectric/issues/1306
- cameraCancelableCallback = null;
-
- handler.post(new Runnable() {
- @Override
- public void run() {
- callback.onFinish();
- }
- });
- }
- cameraChangeDispatcher.onCameraIdle();
- mapView.removeOnCameraDidChangeListener(this);
- }
- }
-
- /**
- * Internal use.
- */
- @UiThread
- public final void moveCamera(@NonNull MapboxMap mapboxMap, CameraUpdate update,
- @Nullable final MapboxMap.CancelableCallback callback) {
- CameraPosition cameraPosition = update.getCameraPosition(mapboxMap);
- if (isValidCameraPosition(cameraPosition)) {
- cancelTransitions();
- cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION);
- nativeMap.jumpTo(cameraPosition.target, cameraPosition.zoom, cameraPosition.tilt, cameraPosition.bearing,
- cameraPosition.padding);
- cameraChangeDispatcher.onCameraIdle();
- invalidateCameraPosition();
- handler.post(new Runnable() {
- @Override
- public void run() {
- if (callback != null) {
- callback.onFinish();
- }
- }
- });
- } else if (callback != null) {
- callback.onFinish();
- }
- }
-
- @UiThread
- final void easeCamera(@NonNull MapboxMap mapboxMap, CameraUpdate update, int durationMs, boolean easingInterpolator,
- @Nullable final MapboxMap.CancelableCallback callback) {
- CameraPosition cameraPosition = update.getCameraPosition(mapboxMap);
- if (isValidCameraPosition(cameraPosition)) {
- cancelTransitions();
- cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION);
-
- if (callback != null) {
- cameraCancelableCallback = callback;
- }
- mapView.addOnCameraDidChangeListener(this);
- nativeMap.easeTo(cameraPosition.target, cameraPosition.zoom, cameraPosition.bearing, cameraPosition.tilt,
- cameraPosition.padding, durationMs, easingInterpolator);
- } else if (callback != null) {
- callback.onFinish();
- }
- }
-
- /**
- * Internal use.
- */
- @UiThread
- public final void animateCamera(@NonNull MapboxMap mapboxMap, CameraUpdate update, int durationMs,
- @Nullable final MapboxMap.CancelableCallback callback) {
- CameraPosition cameraPosition = update.getCameraPosition(mapboxMap);
- if (isValidCameraPosition(cameraPosition)) {
- cancelTransitions();
- cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION);
-
- if (callback != null) {
- cameraCancelableCallback = callback;
- }
- mapView.addOnCameraDidChangeListener(this);
- nativeMap.flyTo(cameraPosition.target, cameraPosition.zoom, cameraPosition.bearing,
- cameraPosition.tilt, cameraPosition.padding, durationMs);
- } else if (callback != null) {
- callback.onFinish();
- }
- }
-
- private boolean isValidCameraPosition(@Nullable CameraPosition cameraPosition) {
- return cameraPosition != null && !cameraPosition.equals(this.cameraPosition);
- }
-
- @UiThread
- @Nullable
- CameraPosition invalidateCameraPosition() {
- if (nativeMap != null) {
- CameraPosition cameraPosition = nativeMap.getCameraPosition();
- if (this.cameraPosition != null && !this.cameraPosition.equals(cameraPosition)) {
- cameraChangeDispatcher.onCameraMove();
- }
-
- this.cameraPosition = cameraPosition;
- }
- return cameraPosition;
- }
-
- void cancelTransitions() {
- // notify user about cancel
- cameraChangeDispatcher.onCameraMoveCanceled();
-
- // notify animateCamera and easeCamera about cancelling
- if (cameraCancelableCallback != null) {
- final MapboxMap.CancelableCallback callback = cameraCancelableCallback;
- cameraChangeDispatcher.onCameraIdle();
-
- // nullification has to happen before Handler#post, see https://github.com/robolectric/robolectric/issues/1306
- cameraCancelableCallback = null;
-
- handler.post(new Runnable() {
- @Override
- public void run() {
- callback.onCancel();
- }
- });
- }
-
- // cancel ongoing transitions
- nativeMap.cancelTransitions();
-
- cameraChangeDispatcher.onCameraIdle();
- }
-
- @UiThread
- void resetNorth() {
- cancelTransitions();
- nativeMap.resetNorth();
- }
-
- //
- // non Camera API
- //
-
- // Zoom in or out
-
- double getRawZoom() {
- return nativeMap.getZoom();
- }
-
- void zoomBy(double zoomAddition, @NonNull PointF focalPoint) {
- setZoom(nativeMap.getZoom() + zoomAddition, focalPoint);
- }
-
- void setZoom(double zoom, @NonNull PointF focalPoint) {
- nativeMap.setZoom(zoom, focalPoint, 0);
- }
-
- // Direction
- double getBearing() {
- double direction = -nativeMap.getBearing();
-
- while (direction > 360) {
- direction -= 360;
- }
- while (direction < 0) {
- direction += 360;
- }
-
- return direction;
- }
-
- double getRawBearing() {
- return nativeMap.getBearing();
- }
-
- void setBearing(double bearing) {
- nativeMap.setBearing(bearing, 0);
- }
-
- void setBearing(double bearing, float focalX, float focalY) {
- nativeMap.setBearing(bearing, focalX, focalY, 0);
- }
-
- void setBearing(double bearing, float focalX, float focalY, long duration) {
- nativeMap.setBearing(bearing, focalX, focalY, duration);
- }
-
-
- //
- // LatLng / CenterCoordinate
- //
-
- LatLng getLatLng() {
- return nativeMap.getLatLng();
- }
-
- //
- // Pitch / Tilt
- //
-
- double getTilt() {
- return nativeMap.getPitch();
- }
-
- void setTilt(Double pitch) {
- nativeMap.setPitch(pitch, 0);
- }
-
- //
- // Center coordinate
- //
-
- LatLng getCenterCoordinate() {
- return nativeMap.getLatLng();
- }
-
- void setCenterCoordinate(LatLng centerCoordinate) {
- nativeMap.setLatLng(centerCoordinate, 0);
- }
-
- void setGestureInProgress(boolean gestureInProgress) {
- nativeMap.setGestureInProgress(gestureInProgress);
- if (!gestureInProgress) {
- invalidateCameraPosition();
- }
- }
-
- void moveBy(double offsetX, double offsetY, long duration) {
- if (duration > 0) {
- mapView.addOnCameraDidChangeListener(moveByChangeListener);
- }
- nativeMap.moveBy(offsetX, offsetY, duration);
- }
-
- //
- // Min & Max ZoomLevel
- //
-
- void setMinZoom(double minZoom) {
- if ((minZoom < MapboxConstants.MINIMUM_ZOOM) || (minZoom > MapboxConstants.MAXIMUM_ZOOM)) {
- Logger.e(TAG, String.format("Not setting minZoomPreference, value is in unsupported range: %s", minZoom));
- return;
- }
- nativeMap.setMinZoom(minZoom);
- }
-
- double getMinZoom() {
- return nativeMap.getMinZoom();
- }
-
- void setMaxZoom(double maxZoom) {
- if ((maxZoom < MapboxConstants.MINIMUM_ZOOM) || (maxZoom > MapboxConstants.MAXIMUM_ZOOM)) {
- Logger.e(TAG, String.format("Not setting maxZoomPreference, value is in unsupported range: %s", maxZoom));
- return;
- }
- nativeMap.setMaxZoom(maxZoom);
- }
-
- double getMaxZoom() {
- return nativeMap.getMaxZoom();
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java
deleted file mode 100644
index 3fd155837e..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java
+++ /dev/null
@@ -1,1103 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Color;
-import android.graphics.PointF;
-import android.graphics.drawable.Drawable;
-import android.os.Build;
-import android.os.Bundle;
-import android.support.annotation.ColorInt;
-import android.support.annotation.FloatRange;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.annotation.Px;
-import android.support.annotation.UiThread;
-import android.support.v4.content.ContextCompat;
-import android.support.v4.content.res.ResourcesCompat;
-import android.view.View;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
-
-import com.mapbox.mapboxsdk.R;
-import com.mapbox.mapboxsdk.camera.CameraPosition;
-import com.mapbox.mapboxsdk.constants.MapboxConstants;
-import com.mapbox.mapboxsdk.maps.widgets.CompassView;
-import com.mapbox.mapboxsdk.utils.BitmapUtils;
-import com.mapbox.mapboxsdk.utils.ColorUtils;
-
-/**
- * Settings for the user interface of a MapboxMap. To obtain this interface, call getUiSettings().
- */
-public final class UiSettings {
-
- @NonNull
- private final FocalPointChangeListener focalPointChangeListener;
- @NonNull
- private final Projection projection;
- @NonNull
- private final CompassView compassView;
- private final int[] compassMargins = new int[4];
-
- @NonNull
- private final ImageView attributionsView;
- private final int[] attributionsMargins = new int[4];
- private AttributionDialogManager attributionDialogManager;
-
- @NonNull
- private final View logoView;
- private final int[] logoMargins = new int[4];
-
- private final float pixelRatio;
-
- private boolean rotateGesturesEnabled = true;
-
- private boolean tiltGesturesEnabled = true;
-
- private boolean zoomGesturesEnabled = true;
-
- private boolean scrollGesturesEnabled = true;
-
- private boolean doubleTapGesturesEnabled = true;
-
- private boolean quickZoomGesturesEnabled = true;
-
- private boolean scaleVelocityAnimationEnabled = true;
- private boolean rotateVelocityAnimationEnabled = true;
- private boolean flingVelocityAnimationEnabled = true;
-
- private boolean increaseRotateThresholdWhenScaling = true;
- private boolean disableRotateWhenScaling = true;
- private boolean increaseScaleThresholdWhenRotating = true;
-
- private float zoomRate = 1.0f;
-
- private boolean deselectMarkersOnTap = true;
-
- @Nullable
- private PointF userProvidedFocalPoint;
-
- UiSettings(@NonNull Projection projection, @NonNull FocalPointChangeListener listener,
- @NonNull CompassView compassView, @NonNull ImageView attributionsView, @NonNull View logoView,
- float pixelRatio) {
- this.projection = projection;
- this.focalPointChangeListener = listener;
- this.compassView = compassView;
- this.attributionsView = attributionsView;
- this.logoView = logoView;
- this.pixelRatio = pixelRatio;
- }
-
- void initialise(@NonNull Context context, @NonNull MapboxMapOptions options) {
- Resources resources = context.getResources();
- initialiseGestures(options);
- initialiseCompass(options, resources);
- initialiseLogo(options, resources);
- initialiseAttribution(context, options);
- }
-
- void onSaveInstanceState(@NonNull Bundle outState) {
- saveGestures(outState);
- saveCompass(outState);
- saveLogo(outState);
- saveAttribution(outState);
- saveDeselectMarkersOnTap(outState);
- saveFocalPoint(outState);
- }
-
- void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
- restoreGestures(savedInstanceState);
- restoreCompass(savedInstanceState);
- restoreLogo(savedInstanceState);
- restoreAttribution(savedInstanceState);
- restoreDeselectMarkersOnTap(savedInstanceState);
- restoreFocalPoint(savedInstanceState);
- }
-
- private void initialiseGestures(MapboxMapOptions options) {
- setZoomGesturesEnabled(options.getZoomGesturesEnabled());
- setScrollGesturesEnabled(options.getScrollGesturesEnabled());
- setRotateGesturesEnabled(options.getRotateGesturesEnabled());
- setTiltGesturesEnabled(options.getTiltGesturesEnabled());
- setDoubleTapGesturesEnabled(options.getDoubleTapGesturesEnabled());
- setQuickZoomGesturesEnabled(options.getQuickZoomGesturesEnabled());
- }
-
- private void saveGestures(Bundle outState) {
- outState.putBoolean(MapboxConstants.STATE_ZOOM_ENABLED, isZoomGesturesEnabled());
- outState.putBoolean(MapboxConstants.STATE_SCROLL_ENABLED, isScrollGesturesEnabled());
- outState.putBoolean(MapboxConstants.STATE_ROTATE_ENABLED, isRotateGesturesEnabled());
- outState.putBoolean(MapboxConstants.STATE_TILT_ENABLED, isTiltGesturesEnabled());
- outState.putBoolean(MapboxConstants.STATE_DOUBLE_TAP_ENABLED, isDoubleTapGesturesEnabled());
- outState.putBoolean(MapboxConstants.STATE_SCALE_ANIMATION_ENABLED, isScaleVelocityAnimationEnabled());
- outState.putBoolean(MapboxConstants.STATE_ROTATE_ANIMATION_ENABLED, isRotateVelocityAnimationEnabled());
- outState.putBoolean(MapboxConstants.STATE_FLING_ANIMATION_ENABLED, isFlingVelocityAnimationEnabled());
- outState.putBoolean(MapboxConstants.STATE_INCREASE_ROTATE_THRESHOLD, isIncreaseRotateThresholdWhenScaling());
- outState.putBoolean(MapboxConstants.STATE_DISABLE_ROTATE_WHEN_SCALING, isDisableRotateWhenScaling());
- outState.putBoolean(MapboxConstants.STATE_INCREASE_SCALE_THRESHOLD, isIncreaseScaleThresholdWhenRotating());
- outState.putBoolean(MapboxConstants.STATE_QUICK_ZOOM_ENABLED, isQuickZoomGesturesEnabled());
- outState.putFloat(MapboxConstants.STATE_ZOOM_RATE, getZoomRate());
- }
-
- private void restoreGestures(Bundle savedInstanceState) {
- setZoomGesturesEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_ZOOM_ENABLED));
- setScrollGesturesEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_SCROLL_ENABLED));
- setRotateGesturesEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_ROTATE_ENABLED));
- setTiltGesturesEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_TILT_ENABLED));
- setDoubleTapGesturesEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_DOUBLE_TAP_ENABLED));
- setScaleVelocityAnimationEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_SCALE_ANIMATION_ENABLED));
- setRotateVelocityAnimationEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_ROTATE_ANIMATION_ENABLED));
- setFlingVelocityAnimationEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_FLING_ANIMATION_ENABLED));
- setIncreaseRotateThresholdWhenScaling(
- savedInstanceState.getBoolean(MapboxConstants.STATE_INCREASE_ROTATE_THRESHOLD));
- setDisableRotateWhenScaling(savedInstanceState.getBoolean(MapboxConstants.STATE_DISABLE_ROTATE_WHEN_SCALING));
- setIncreaseScaleThresholdWhenRotating(
- savedInstanceState.getBoolean(MapboxConstants.STATE_INCREASE_SCALE_THRESHOLD));
- setQuickZoomGesturesEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_QUICK_ZOOM_ENABLED));
- setZoomRate(savedInstanceState.getFloat(MapboxConstants.STATE_ZOOM_RATE, 1.0f));
- }
-
- private void initialiseCompass(MapboxMapOptions options, @NonNull Resources resources) {
- setCompassEnabled(options.getCompassEnabled());
- setCompassGravity(options.getCompassGravity());
- int[] compassMargins = options.getCompassMargins();
- if (compassMargins != null) {
- setCompassMargins(compassMargins[0], compassMargins[1], compassMargins[2], compassMargins[3]);
- } else {
- int tenDp = (int) resources.getDimension(R.dimen.mapbox_four_dp);
- setCompassMargins(tenDp, tenDp, tenDp, tenDp);
- }
- setCompassFadeFacingNorth(options.getCompassFadeFacingNorth());
- if (options.getCompassImage() == null) {
- options.compassImage(ResourcesCompat.getDrawable(resources, R.drawable.mapbox_compass_icon, null));
- }
- setCompassImage(options.getCompassImage());
- }
-
- private void saveCompass(Bundle outState) {
- outState.putBoolean(MapboxConstants.STATE_COMPASS_ENABLED, isCompassEnabled());
- outState.putInt(MapboxConstants.STATE_COMPASS_GRAVITY, getCompassGravity());
- outState.putInt(MapboxConstants.STATE_COMPASS_MARGIN_LEFT, getCompassMarginLeft());
- outState.putInt(MapboxConstants.STATE_COMPASS_MARGIN_TOP, getCompassMarginTop());
- outState.putInt(MapboxConstants.STATE_COMPASS_MARGIN_BOTTOM, getCompassMarginBottom());
- outState.putInt(MapboxConstants.STATE_COMPASS_MARGIN_RIGHT, getCompassMarginRight());
- outState.putBoolean(MapboxConstants.STATE_COMPASS_FADE_WHEN_FACING_NORTH, isCompassFadeWhenFacingNorth());
- outState.putByteArray(MapboxConstants.STATE_COMPASS_IMAGE_BITMAP,
- BitmapUtils.getByteArrayFromDrawable(getCompassImage()));
- }
-
- private void restoreCompass(Bundle savedInstanceState) {
- setCompassEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_COMPASS_ENABLED));
- setCompassGravity(savedInstanceState.getInt(MapboxConstants.STATE_COMPASS_GRAVITY));
- setCompassMargins(savedInstanceState.getInt(MapboxConstants.STATE_COMPASS_MARGIN_LEFT),
- savedInstanceState.getInt(MapboxConstants.STATE_COMPASS_MARGIN_TOP),
- savedInstanceState.getInt(MapboxConstants.STATE_COMPASS_MARGIN_RIGHT),
- savedInstanceState.getInt(MapboxConstants.STATE_COMPASS_MARGIN_BOTTOM));
- setCompassFadeFacingNorth(savedInstanceState.getBoolean(MapboxConstants.STATE_COMPASS_FADE_WHEN_FACING_NORTH));
- setCompassImage(BitmapUtils.getDrawableFromByteArray(
- compassView.getContext(), savedInstanceState.getByteArray(MapboxConstants.STATE_COMPASS_IMAGE_BITMAP)));
- }
-
- private void initialiseLogo(MapboxMapOptions options, @NonNull Resources resources) {
- setLogoEnabled(options.getLogoEnabled());
- setLogoGravity(options.getLogoGravity());
- setLogoMargins(resources, options.getLogoMargins());
- }
-
- private void setLogoMargins(@NonNull Resources resources, @Nullable int[] logoMargins) {
- if (logoMargins != null) {
- setLogoMargins(logoMargins[0], logoMargins[1], logoMargins[2], logoMargins[3]);
- } else {
- // user did not specify margins when programmatically creating a map
- int fourDp = (int) resources.getDimension(R.dimen.mapbox_four_dp);
- setLogoMargins(fourDp, fourDp, fourDp, fourDp);
- }
- }
-
- private void saveLogo(Bundle outState) {
- outState.putInt(MapboxConstants.STATE_LOGO_GRAVITY, getLogoGravity());
- outState.putInt(MapboxConstants.STATE_LOGO_MARGIN_LEFT, getLogoMarginLeft());
- outState.putInt(MapboxConstants.STATE_LOGO_MARGIN_TOP, getLogoMarginTop());
- outState.putInt(MapboxConstants.STATE_LOGO_MARGIN_RIGHT, getLogoMarginRight());
- outState.putInt(MapboxConstants.STATE_LOGO_MARGIN_BOTTOM, getLogoMarginBottom());
- outState.putBoolean(MapboxConstants.STATE_LOGO_ENABLED, isLogoEnabled());
- }
-
- private void restoreLogo(Bundle savedInstanceState) {
- setLogoEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_LOGO_ENABLED));
- setLogoGravity(savedInstanceState.getInt(MapboxConstants.STATE_LOGO_GRAVITY));
- setLogoMargins(savedInstanceState.getInt(MapboxConstants.STATE_LOGO_MARGIN_LEFT),
- savedInstanceState.getInt(MapboxConstants.STATE_LOGO_MARGIN_TOP),
- savedInstanceState.getInt(MapboxConstants.STATE_LOGO_MARGIN_RIGHT),
- savedInstanceState.getInt(MapboxConstants.STATE_LOGO_MARGIN_BOTTOM));
- }
-
- private void initialiseAttribution(@NonNull Context context, MapboxMapOptions options) {
- setAttributionEnabled(options.getAttributionEnabled());
- setAttributionGravity(options.getAttributionGravity());
- setAttributionMargins(context, options.getAttributionMargins());
- int attributionTintColor = options.getAttributionTintColor();
- setAttributionTintColor(attributionTintColor != -1
- ? attributionTintColor : ColorUtils.getPrimaryColor(context));
- }
-
- private void setAttributionMargins(@NonNull Context context, @Nullable int[] attributionMargins) {
- if (attributionMargins != null) {
- setAttributionMargins(attributionMargins[0], attributionMargins[1],
- attributionMargins[2], attributionMargins[3]);
- } else {
- // user did not specify margins when programmatically creating a map
- Resources resources = context.getResources();
- int margin = (int) resources.getDimension(R.dimen.mapbox_four_dp);
- int leftMargin = (int) resources.getDimension(R.dimen.mapbox_ninety_two_dp);
- setAttributionMargins(leftMargin, margin, margin, margin);
- }
- }
-
- private void saveAttribution(Bundle outState) {
- outState.putInt(MapboxConstants.STATE_ATTRIBUTION_GRAVITY, getAttributionGravity());
- outState.putInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_LEFT, getAttributionMarginLeft());
- outState.putInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_TOP, getAttributionMarginTop());
- outState.putInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_RIGHT, getAttributionMarginRight());
- outState.putInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_BOTTOM, getAttributionMarginBottom());
- outState.putBoolean(MapboxConstants.STATE_ATTRIBUTION_ENABLED, isAttributionEnabled());
- }
-
- private void restoreAttribution(Bundle savedInstanceState) {
- setAttributionEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_ATTRIBUTION_ENABLED));
- setAttributionGravity(savedInstanceState.getInt(MapboxConstants.STATE_ATTRIBUTION_GRAVITY));
- setAttributionMargins(savedInstanceState.getInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_LEFT),
- savedInstanceState.getInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_TOP),
- savedInstanceState.getInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_RIGHT),
- savedInstanceState.getInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_BOTTOM));
- }
-
- /**
- * <p>
- * Enables or disables the compass. The compass is an icon on the map that indicates the
- * direction of north on the map. When a user clicks
- * the compass, the camera orients itself to its default orientation and fades away shortly
- * after. If disabled, the compass will never be displayed.
- * </p>
- * By default, the compass is enabled.
- *
- * @param compassEnabled True to enable the compass; false to disable the compass.
- */
- public void setCompassEnabled(boolean compassEnabled) {
- compassView.setEnabled(compassEnabled);
- }
-
- /**
- * Returns whether the compass is enabled.
- *
- * @return True if the compass is enabled; false if the compass is disabled.
- */
- public boolean isCompassEnabled() {
- return compassView.isEnabled();
- }
-
- /**
- * <p>
- * Sets the gravity of the compass view. Use this to change the corner of the map view that the
- * compass is displayed in.
- * </p>
- * By default, the compass is in the top right corner.
- *
- * @param gravity Android SDK Gravity.
- */
- @UiThread
- public void setCompassGravity(int gravity) {
- setWidgetGravity(compassView, gravity);
- }
-
- /**
- * Enables or disables fading of the compass when facing north.
- * <p>
- * By default this feature is enabled
- * </p>
- *
- * @param compassFadeFacingNorth True to enable the fading animation; false to disable it
- */
- public void setCompassFadeFacingNorth(boolean compassFadeFacingNorth) {
- compassView.fadeCompassViewFacingNorth(compassFadeFacingNorth);
- }
-
- /**
- * Specifies the CompassView image.
- * <p>
- * By default this value is R.drawable.mapbox_compass_icon.
- * </p>
- *
- * @param compass the drawable to show as image compass
- */
- public void setCompassImage(@NonNull Drawable compass) {
- compassView.setCompassImage(compass);
- }
-
- /**
- * Returns whether the compass performs a fading animation out when facing north.
- *
- * @return True if the compass will fade, false if it remains visible
- */
- public boolean isCompassFadeWhenFacingNorth() {
- return compassView.isFadeCompassViewFacingNorth();
- }
-
- /**
- * Returns the gravity value of the CompassView
- *
- * @return The gravity
- */
- public int getCompassGravity() {
- return ((FrameLayout.LayoutParams) compassView.getLayoutParams()).gravity;
- }
-
- /**
- * Sets the margins of the compass view in pixels. Use this to change the distance of the compass from the
- * map view edge.
- *
- * @param left The left margin in pixels.
- * @param top The top margin in pixels.
- * @param right The right margin in pixels.
- * @param bottom The bottom margin in pixels.
- */
- @UiThread
- public void setCompassMargins(@Px int left, @Px int top, @Px int right, @Px int bottom) {
- setWidgetMargins(compassView, compassMargins, left, top, right, bottom);
- }
-
- /**
- * Returns the left side margin of CompassView in pixels.
- *
- * @return The left margin in pixels
- */
- @Px
- public int getCompassMarginLeft() {
- return compassMargins[0];
- }
-
- /**
- * Returns the top side margin of CompassView in pixels.
- *
- * @return The top margin in pixels
- */
- @Px
- public int getCompassMarginTop() {
- return compassMargins[1];
- }
-
- /**
- * Returns the right side margin of CompassView in pixels.
- *
- * @return The right margin in pixels
- */
- @Px
- public int getCompassMarginRight() {
- return compassMargins[2];
- }
-
- /**
- * Returns the bottom side margin of CompassView in pixels.
- *
- * @return The bottom margin in pixels
- */
- @Px
- public int getCompassMarginBottom() {
- return compassMargins[3];
- }
-
- /**
- * Get the current configured CompassView image.
- *
- * @return the drawable used as compass image
- */
- @NonNull
- public Drawable getCompassImage() {
- return compassView.getCompassImage();
- }
-
- void update(@NonNull CameraPosition cameraPosition) {
- double clockwiseBearing = -cameraPosition.bearing;
- compassView.update(clockwiseBearing);
- }
-
- /**
- * <p>
- * Enables or disables the Mapbox logo.
- * </p>
- * By default, the logo is enabled.
- *
- * @param enabled True to enable the logo; false to disable the logo.
- */
- public void setLogoEnabled(boolean enabled) {
- logoView.setVisibility(enabled ? View.VISIBLE : View.GONE);
- }
-
- /**
- * Returns whether the logo is enabled.
- *
- * @return True if the logo is enabled; false if the logo is disabled.
- */
- public boolean isLogoEnabled() {
- return logoView.getVisibility() == View.VISIBLE;
- }
-
- /**
- * <p>
- * Sets the gravity of the logo view. Use this to change the corner of the map view that the
- * Mapbox logo is displayed in.
- * </p>
- * By default, the logo is in the bottom left corner.
- *
- * @param gravity Android SDK Gravity.
- */
- public void setLogoGravity(int gravity) {
- setWidgetGravity(logoView, gravity);
- }
-
- /**
- * Returns the gravity value of the logo
- *
- * @return The gravity
- */
- public int getLogoGravity() {
- return ((FrameLayout.LayoutParams) logoView.getLayoutParams()).gravity;
- }
-
- /**
- * Sets the margins of the logo view in pixels. Use this to change the distance of the Mapbox logo from the
- * map view edge.
- *
- * @param left The left margin in pixels.
- * @param top The top margin in pixels.
- * @param right The right margin in pixels.
- * @param bottom The bottom margin in pixels.
- */
- public void setLogoMargins(@Px int left, @Px int top, @Px int right, @Px int bottom) {
- setWidgetMargins(logoView, logoMargins, left, top, right, bottom);
- }
-
- /**
- * Returns the left side margin of the logo in pixels.
- *
- * @return The left margin in pixels
- */
- @Px
- public int getLogoMarginLeft() {
- return logoMargins[0];
- }
-
- /**
- * Returns the top side margin of the logo in pixels.
- *
- * @return The top margin in pixels
- */
- @Px
- public int getLogoMarginTop() {
- return logoMargins[1];
- }
-
- /**
- * Returns the right side margin of the logo in pixels.
- *
- * @return The right margin in pixels
- */
- @Px
- public int getLogoMarginRight() {
- return logoMargins[2];
- }
-
- /**
- * Returns the bottom side margin of the logo in pixels.
- *
- * @return The bottom margin in pixels
- */
- @Px
- public int getLogoMarginBottom() {
- return logoMargins[3];
- }
-
- /**
- * <p>
- * Enables or disables the attribution.
- * </p>
- * By default, the attribution is enabled.
- *
- * @param enabled True to enable the attribution; false to disable the attribution.
- */
- public void setAttributionEnabled(boolean enabled) {
- attributionsView.setVisibility(enabled ? View.VISIBLE : View.GONE);
- }
-
- /**
- * Returns whether the attribution is enabled.
- *
- * @return True if the attribution is enabled; false if the attribution is disabled.
- */
- public boolean isAttributionEnabled() {
- return attributionsView.getVisibility() == View.VISIBLE;
- }
-
-
- /**
- * Set a custom attribution dialog manager.
- * <p>
- * Set to null to reset to default behaviour.
- * </p>
- *
- * @param attributionDialogManager the manager class used for showing attribution
- */
- public void setAttributionDialogManager(@NonNull AttributionDialogManager attributionDialogManager) {
- this.attributionDialogManager = attributionDialogManager;
- }
-
- /**
- * Get the custom attribution dialog manager.
- *
- * @return the active manager class used for showing attribution
- */
- @Nullable
- public AttributionDialogManager getAttributionDialogManager() {
- return attributionDialogManager;
- }
-
- /**
- * <p>
- * Sets the gravity of the attribution.
- * </p>
- * By default, the attribution is in the bottom left corner next to the Mapbox logo.
- *
- * @param gravity Android SDK Gravity.
- */
- public void setAttributionGravity(int gravity) {
- setWidgetGravity(attributionsView, gravity);
- }
-
- /**
- * Returns the gravity value of the logo
- *
- * @return The gravity
- */
- public int getAttributionGravity() {
- return ((FrameLayout.LayoutParams) attributionsView.getLayoutParams()).gravity;
- }
-
- /**
- * Sets the margins of the attribution view in pixels.
- *
- * @param left The left margin in pixels.
- * @param top The top margin in pixels.
- * @param right The right margin in pixels.
- * @param bottom The bottom margin in pixels.
- */
- public void setAttributionMargins(@Px int left, @Px int top, @Px int right, @Px int bottom) {
- setWidgetMargins(attributionsView, attributionsMargins, left, top, right, bottom);
- }
-
- /**
- * <p>
- * Sets the tint of the attribution view. Use this to change the color of the attribution.
- * </p>
- *
- * @param tintColor Color to tint the attribution.
- */
- public void setAttributionTintColor(@ColorInt int tintColor) {
- // Check that the tint color being passed in isn't transparent.
- if (Color.alpha(tintColor) == 0) {
- ColorUtils.setTintList(attributionsView,
- ContextCompat.getColor(attributionsView.getContext(), R.color.mapbox_blue));
- } else {
- ColorUtils.setTintList(attributionsView, tintColor);
- }
- }
-
- /**
- * Returns the left side margin of the attribution view in pixels.
- *
- * @return The left margin in pixels
- */
- @Px
- public int getAttributionMarginLeft() {
- return attributionsMargins[0];
- }
-
- /**
- * Returns the top side margin of the attribution view in pixels.
- *
- * @return The top margin in pixels
- */
- @Px
- public int getAttributionMarginTop() {
- return attributionsMargins[1];
- }
-
- /**
- * Returns the right side margin of the attribution view in pixels.
- *
- * @return The right margin in pixels
- */
- @Px
- public int getAttributionMarginRight() {
- return attributionsMargins[2];
- }
-
- /**
- * Returns the bottom side margin of the logo in pixels.
- *
- * @return The bottom margin in pixels
- */
- @Px
- public int getAttributionMarginBottom() {
- return attributionsMargins[3];
- }
-
- /**
- * <p>
- * Changes whether the user may rotate the map.
- * </p>
- * <p>
- * This setting controls only user interactions with the map. If you set the value to false,
- * you may still change the map location programmatically.
- * </p>
- * The default value is true.
- *
- * @param rotateGesturesEnabled If true, rotating is enabled.
- */
- public void setRotateGesturesEnabled(boolean rotateGesturesEnabled) {
- this.rotateGesturesEnabled = rotateGesturesEnabled;
- }
-
- /**
- * Returns whether the user may rotate the map.
- *
- * @return If true, rotating is enabled.
- */
- public boolean isRotateGesturesEnabled() {
- return rotateGesturesEnabled;
- }
-
- /**
- * <p>
- * Changes whether the user may tilt the map.
- * </p>
- * <p>
- * This setting controls only user interactions with the map. If you set the value to false,
- * you may still change the map location programmatically.
- * </p>
- * The default value is true.
- *
- * @param tiltGesturesEnabled If true, tilting is enabled.
- */
- public void setTiltGesturesEnabled(boolean tiltGesturesEnabled) {
- this.tiltGesturesEnabled = tiltGesturesEnabled;
-
- }
-
- /**
- * Returns whether the user may tilt the map.
- *
- * @return If true, tilting is enabled.
- */
- public boolean isTiltGesturesEnabled() {
- return tiltGesturesEnabled;
- }
-
- /**
- * <p>
- * Changes whether the user may zoom the map.
- * </p>
- * <p>
- * This setting controls only user interactions with the map. If you set the value to false,
- * you may still change the map location programmatically.
- * </p>
- * The default value is true.
- *
- * @param zoomGesturesEnabled If true, zooming is enabled.
- */
- public void setZoomGesturesEnabled(boolean zoomGesturesEnabled) {
- this.zoomGesturesEnabled = zoomGesturesEnabled;
- }
-
- /**
- * Returns whether the user may zoom the map.
- *
- * @return If true, zooming is enabled.
- */
- public boolean isZoomGesturesEnabled() {
- return zoomGesturesEnabled;
- }
-
- /**
- * <p>
- * Changes whether the user may zoom the map with a double tap.
- * </p>
- * <p>
- * This setting controls only user interactions with the map. If you set the value to false,
- * you may still change the map location programmatically.
- * </p>
- * The default value is true.
- *
- * @param doubleTapGesturesEnabled If true, zooming with a double tap is enabled.
- */
- public void setDoubleTapGesturesEnabled(boolean doubleTapGesturesEnabled) {
- this.doubleTapGesturesEnabled = doubleTapGesturesEnabled;
- }
-
- /**
- * Returns whether the user may zoom the map with a double tap.
- *
- * @return If true, zooming with a double tap is enabled.
- */
- public boolean isDoubleTapGesturesEnabled() {
- return doubleTapGesturesEnabled;
- }
-
- /**
- * Returns whether the user may zoom the map by tapping twice, holding and moving the pointer up and down.
- *
- * @return If true, zooming by tapping twice and holding is enabled.
- */
- public boolean isQuickZoomGesturesEnabled() {
- return quickZoomGesturesEnabled;
- }
-
- /**
- * Changes whether the user may zoom the map by tapping twice, holding and moving the pointer up and down.
- * <p>
- * This setting controls only user interactions with the map. If you set the value to false,
- * you may still change the map location programmatically.
- * </p>
- * The default value is true.
- *
- * @param quickZoomGesturesEnabled If true, zooming by tapping twice and holding is enabled.
- */
- public void setQuickZoomGesturesEnabled(boolean quickZoomGesturesEnabled) {
- this.quickZoomGesturesEnabled = quickZoomGesturesEnabled;
- }
-
- /**
- * Returns zoom gesture rate, including pinch to zoom and quick scale.
- *
- * @return The zoom rate.
- */
- public float getZoomRate() {
- return zoomRate;
- }
-
- /**
- * Sets zoom gesture rate, including pinch to zoom and quick scale.
- * <p>
- * Default value is 1.0f.
- * </p>
- *
- * @param zoomRate The zoom rate.
- */
- public void setZoomRate(@FloatRange(from = 0f) float zoomRate) {
- this.zoomRate = zoomRate;
- }
-
- private void restoreDeselectMarkersOnTap(Bundle savedInstanceState) {
- setDeselectMarkersOnTap(savedInstanceState.getBoolean(MapboxConstants.STATE_DESELECT_MARKER_ON_TAP));
- }
-
- private void saveDeselectMarkersOnTap(Bundle outState) {
- outState.putBoolean(MapboxConstants.STATE_DESELECT_MARKER_ON_TAP, isDeselectMarkersOnTap());
- }
-
- /**
- * Gets whether the markers are automatically deselected (and therefore, their infowindows
- * closed) when a map tap is detected.
- *
- * @return If true, markers are deselected on a map tap.
- */
- public boolean isDeselectMarkersOnTap() {
- return deselectMarkersOnTap;
- }
-
- /**
- * Sets whether the markers are automatically deselected (and therefore, their infowindows
- * closed) when a map tap is detected.
- *
- * @param deselectMarkersOnTap determines if markers should be deslected on tap
- */
- public void setDeselectMarkersOnTap(boolean deselectMarkersOnTap) {
- this.deselectMarkersOnTap = deselectMarkersOnTap;
- }
-
- /**
- * <p>
- * Changes whether the user may scroll around the map.
- * </p>
- * <p>
- * This setting controls only user interactions with the map. If you set the value to false,
- * you may still change the map location programmatically.
- * </p>
- * The default value is true.
- *
- * @param scrollGesturesEnabled If true, scrolling is enabled.
- */
- public void setScrollGesturesEnabled(boolean scrollGesturesEnabled) {
- this.scrollGesturesEnabled = scrollGesturesEnabled;
- }
-
- /**
- * Returns whether the user may scroll around the map.
- *
- * @return If true, scrolling is enabled.
- */
- public boolean isScrollGesturesEnabled() {
- return scrollGesturesEnabled;
- }
-
- /**
- * Returns whether scale velocity animation should execute after users finishes a gesture.
- *
- * @return If true, scale velocity animation is enabled.
- */
- public boolean isScaleVelocityAnimationEnabled() {
- return scaleVelocityAnimationEnabled;
- }
-
- /**
- * Set whether scale velocity animation should execute after users finishes a gesture. True by default.
- *
- * @param scaleVelocityAnimationEnabled If true, scale velocity animation will be enabled.
- */
- public void setScaleVelocityAnimationEnabled(boolean scaleVelocityAnimationEnabled) {
- this.scaleVelocityAnimationEnabled = scaleVelocityAnimationEnabled;
- }
-
- /**
- * Returns whether rotate velocity animation should execute after users finishes a gesture.
- *
- * @return If true, rotate velocity animation is enabled.
- */
- public boolean isRotateVelocityAnimationEnabled() {
- return rotateVelocityAnimationEnabled;
- }
-
- /**
- * Set whether rotate velocity animation should execute after users finishes a gesture. True by default.
- *
- * @param rotateVelocityAnimationEnabled If true, rotate velocity animation will be enabled.
- */
- public void setRotateVelocityAnimationEnabled(boolean rotateVelocityAnimationEnabled) {
- this.rotateVelocityAnimationEnabled = rotateVelocityAnimationEnabled;
- }
-
- /**
- * Returns whether fling velocity animation should execute after users finishes a gesture.
- *
- * @return If true, fling velocity animation is enabled.
- */
- public boolean isFlingVelocityAnimationEnabled() {
- return flingVelocityAnimationEnabled;
- }
-
- /**
- * Set whether fling velocity animation should execute after users finishes a gesture. True by default.
- *
- * @param flingVelocityAnimationEnabled If true, fling velocity animation will be enabled.
- */
- public void setFlingVelocityAnimationEnabled(boolean flingVelocityAnimationEnabled) {
- this.flingVelocityAnimationEnabled = flingVelocityAnimationEnabled;
- }
-
- /**
- * Set whether all velocity animations should execute after users finishes a gesture.
- *
- * @param allVelocityAnimationsEnabled If true, all velocity animations will be enabled.
- */
- public void setAllVelocityAnimationsEnabled(boolean allVelocityAnimationsEnabled) {
- setScaleVelocityAnimationEnabled(allVelocityAnimationsEnabled);
- setRotateVelocityAnimationEnabled(allVelocityAnimationsEnabled);
- setFlingVelocityAnimationEnabled(allVelocityAnimationsEnabled);
- }
-
- /**
- * Returns whether rotation threshold should be increase whenever scale is detected.
- *
- * @return If true, rotation threshold will be increased.
- * @deprecated unused, see {@link #isDisableRotateWhenScaling()} instead
- */
- @Deprecated
- public boolean isIncreaseRotateThresholdWhenScaling() {
- return increaseRotateThresholdWhenScaling;
- }
-
- /**
- * Set whether rotation threshold should be increase whenever scale is detected.
- *
- * @param increaseRotateThresholdWhenScaling If true, rotation threshold will be increased.
- * @deprecated unused, see {@link #setDisableRotateWhenScaling(boolean)} instead
- */
- @Deprecated
- public void setIncreaseRotateThresholdWhenScaling(boolean increaseRotateThresholdWhenScaling) {
- this.increaseRotateThresholdWhenScaling = increaseRotateThresholdWhenScaling;
- }
-
- /**
- * Returns whether rotation gesture detector is disabled when scale is detected first.
- *
- * @return If true, rotation gesture detector will be disabled when scale is detected first.
- */
- public boolean isDisableRotateWhenScaling() {
- return disableRotateWhenScaling;
- }
-
- /**
- * Set whether rotation gesture detector should be disabled when scale is detected first.
- *
- * @param disableRotateWhenScaling If true, rotation gesture detector will be disabled when scale is detected first.
- */
- public void setDisableRotateWhenScaling(boolean disableRotateWhenScaling) {
- this.disableRotateWhenScaling = disableRotateWhenScaling;
- }
-
- /**
- * Returns whether scale threshold should be increase whenever rotation is detected.
- *
- * @return If true, scale threshold will be increased.
- */
- public boolean isIncreaseScaleThresholdWhenRotating() {
- return increaseScaleThresholdWhenRotating;
- }
-
- /**
- * set whether scale threshold should be increase whenever rotation is detected.
- *
- * @param increaseScaleThresholdWhenRotating If true, scale threshold will be increased.
- */
- public void setIncreaseScaleThresholdWhenRotating(boolean increaseScaleThresholdWhenRotating) {
- this.increaseScaleThresholdWhenRotating = increaseScaleThresholdWhenRotating;
- }
-
- /**
- * <p>
- * Sets the preference for whether all gestures should be enabled or disabled.
- * </p>
- * <p>
- * This setting controls only user interactions with the map. If you set the value to false,
- * you may still change the map location programmatically.
- * </p>
- * The default value is true.
- *
- * @param enabled If true, all gestures are available; otherwise, all gestures are disabled.
- * @see #setZoomGesturesEnabled(boolean) )
- * @see #setScrollGesturesEnabled(boolean)
- * @see #setRotateGesturesEnabled(boolean)
- * @see #setTiltGesturesEnabled(boolean)
- * @see #setDoubleTapGesturesEnabled(boolean)
- * @see #setQuickZoomGesturesEnabled(boolean)
- */
- public void setAllGesturesEnabled(boolean enabled) {
- setScrollGesturesEnabled(enabled);
- setRotateGesturesEnabled(enabled);
- setTiltGesturesEnabled(enabled);
- setZoomGesturesEnabled(enabled);
- setDoubleTapGesturesEnabled(enabled);
- setQuickZoomGesturesEnabled(enabled);
- }
-
- /**
- * <p>
- * Retrieves the current status of whether all gestures are enabled.
- * </p>
- *
- * @return If true, all gestures are enabled.
- */
- public boolean areAllGesturesEnabled() {
- return rotateGesturesEnabled && tiltGesturesEnabled && zoomGesturesEnabled
- && scrollGesturesEnabled && doubleTapGesturesEnabled && quickZoomGesturesEnabled;
- }
-
- private void saveFocalPoint(Bundle outState) {
- outState.putParcelable(MapboxConstants.STATE_USER_FOCAL_POINT, getFocalPoint());
- }
-
- private void restoreFocalPoint(Bundle savedInstanceState) {
- PointF pointF = savedInstanceState.getParcelable(MapboxConstants.STATE_USER_FOCAL_POINT);
- if (pointF != null) {
- setFocalPoint(pointF);
- }
- }
-
- /**
- * Sets the focal point used as center for a gesture
- *
- * @param focalPoint the focal point to be used.
- */
- public void setFocalPoint(@Nullable PointF focalPoint) {
- this.userProvidedFocalPoint = focalPoint;
- focalPointChangeListener.onFocalPointChanged(focalPoint);
- }
-
- /**
- * Returns the gesture focal point
- *
- * @return The focal point
- */
- @Nullable
- public PointF getFocalPoint() {
- return userProvidedFocalPoint;
- }
-
- /**
- * Returns the measured height of the MapView
- *
- * @return height in pixels
- */
- public float getHeight() {
- return projection.getHeight();
- }
-
- /**
- * Returns the measured width of the MapView
- *
- * @return widht in pixels
- */
- public float getWidth() {
- return projection.getWidth();
- }
-
- float getPixelRatio() {
- return pixelRatio;
- }
-
- /**
- * Invalidates the ViewSettings instances shown on top of the MapView
- */
- public void invalidate() {
- setLogoMargins(getLogoMarginLeft(), getLogoMarginTop(), getLogoMarginRight(), getLogoMarginBottom());
- setCompassEnabled(isCompassEnabled());
- setCompassMargins(getCompassMarginLeft(), getCompassMarginTop(), getCompassMarginRight(), getCompassMarginBottom());
- setAttributionMargins(getAttributionMarginLeft(), getAttributionMarginTop(), getAttributionMarginRight(),
- getAttributionMarginBottom());
- }
-
- private void setWidgetGravity(@NonNull final View view, int gravity) {
- FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
- layoutParams.gravity = gravity;
- view.setLayoutParams(layoutParams);
- }
-
- private void setWidgetMargins(@NonNull final View view, int[] initMargins, int left, int top, int right, int bottom) {
- // keep state of initially set margins
- initMargins[0] = left;
- initMargins[1] = top;
- initMargins[2] = right;
- initMargins[3] = bottom;
-
- // convert initial margins with padding
- FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
- layoutParams.setMargins(left, top, right, bottom);
-
- // support RTL
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
- layoutParams.setMarginStart(left);
- layoutParams.setMarginEnd(right);
- }
-
- view.setLayoutParams(layoutParams);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/package-info.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/package-info.java
deleted file mode 100644
index 08ddc0bf86..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Contains the Mapbox Maps Android Maps API classes.
- */
-package com.mapbox.mapboxsdk.maps;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java
deleted file mode 100644
index 947ed35555..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java
+++ /dev/null
@@ -1,158 +0,0 @@
-package com.mapbox.mapboxsdk.maps.renderer;
-
-import android.content.Context;
-import android.support.annotation.CallSuper;
-import android.support.annotation.Keep;
-import android.support.annotation.NonNull;
-
-import com.mapbox.mapboxsdk.LibraryLoader;
-import com.mapbox.mapboxsdk.log.Logger;
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-
-import javax.microedition.khronos.egl.EGLConfig;
-import javax.microedition.khronos.opengles.GL10;
-
-/**
- * The {@link MapRenderer} encapsulates the GL thread.
- * <p>
- * Performs actions on the GL thread to manage the GL resources and
- * render on the one end and acts as a scheduler to request work to
- * be performed on the GL thread on the other.
- */
-@Keep
-public abstract class MapRenderer implements MapRendererScheduler {
-
- static {
- LibraryLoader.load();
- }
-
- private static final String TAG = "Mbgl-MapRenderer";
-
- // Holds the pointer to the native peer after initialisation
- private long nativePtr = 0;
- private double expectedRenderTime = 0;
- private MapboxMap.OnFpsChangedListener onFpsChangedListener;
-
- public MapRenderer(@NonNull Context context, String localIdeographFontFamily) {
- float pixelRatio = context.getResources().getDisplayMetrics().density;
-
- // Initialise native peer
- nativeInitialize(this, pixelRatio, localIdeographFontFamily);
- }
-
- public void onStart() {
- // Implement if needed
- }
-
- public void onPause() {
- // Implement if needed
- }
-
- public void onResume() {
- // Implement if needed
- }
-
- public void onStop() {
- // Implement if needed
- }
-
- public void onDestroy() {
- // Implement if needed
- }
-
- public void setOnFpsChangedListener(MapboxMap.OnFpsChangedListener listener) {
- onFpsChangedListener = listener;
- }
-
- @CallSuper
- protected void onSurfaceCreated(GL10 gl, EGLConfig config) {
- nativeOnSurfaceCreated();
- }
-
- @CallSuper
- protected void onSurfaceChanged(@NonNull GL10 gl, int width, int height) {
- gl.glViewport(0, 0, width, height);
- nativeOnSurfaceChanged(width, height);
- }
-
- @CallSuper
- protected void onSurfaceDestroyed() {
- nativeOnSurfaceDestroyed();
- }
-
- @CallSuper
- protected void onDrawFrame(GL10 gl) {
- long startTime = System.nanoTime();
- try {
- nativeRender();
- } catch (java.lang.Error error) {
- Logger.e(TAG, error.getMessage());
- }
- long renderTime = System.nanoTime() - startTime;
- if (renderTime < expectedRenderTime) {
- try {
- Thread.sleep((long) ((expectedRenderTime - renderTime) / 1E6));
- } catch (InterruptedException ex) {
- Logger.e(TAG, ex.getMessage());
- }
- }
- if (onFpsChangedListener != null) {
- updateFps();
- }
- }
-
- /**
- * May be called from any thread.
- * <p>
- * Called from the native peer to schedule work on the GL
- * thread. Explicit override for easier to read jni code.
- *
- * @param runnable the runnable to execute
- * @see MapRendererRunnable
- */
- @CallSuper
- void queueEvent(MapRendererRunnable runnable) {
- this.queueEvent((Runnable) runnable);
- }
-
- private native void nativeInitialize(MapRenderer self,
- float pixelRatio,
- String localIdeographFontFamily);
-
- @CallSuper
- @Override
- protected native void finalize() throws Throwable;
-
- private native void nativeOnSurfaceCreated();
-
- private native void nativeOnSurfaceChanged(int width, int height);
-
- private native void nativeOnSurfaceDestroyed();
-
- protected native void nativeReset();
-
- private native void nativeRender();
-
- private long timeElapsed;
-
- private void updateFps() {
- long currentTime = System.nanoTime();
- double fps = 1E9 / ((currentTime - timeElapsed));
- onFpsChangedListener.onFpsChanged(fps);
- timeElapsed = currentTime;
- }
-
- /**
- * The max frame rate at which this render is rendered,
- * but it can't excess the ability of device hardware.
- *
- * @param maximumFps Can be set to arbitrary integer values.
- */
- public void setMaximumFps(int maximumFps) {
- if (maximumFps <= 0) {
- // Not valid, just return
- return;
- }
- expectedRenderTime = 1E9 / maximumFps;
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRendererRunnable.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRendererRunnable.java
deleted file mode 100644
index 2ec82ea202..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRendererRunnable.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.mapbox.mapboxsdk.maps.renderer;
-
-import android.support.annotation.Keep;
-
-/**
- * Peer class for {@link Runnable}s to be scheduled on the {@link MapRenderer} thread.
- * The actual work is performed in the native peer.
- */
-@Keep
-class MapRendererRunnable implements Runnable {
-
- // Holds the pointer to the native peer after initialisation
- private final long nativePtr;
-
- /**
- * Constructed from the native peer constructor
- *
- * @param nativePtr the native peer's memory address
- */
- MapRendererRunnable(long nativePtr) {
- this.nativePtr = nativePtr;
- }
-
- @Override
- public native void run();
-
- @Override
- protected native void finalize() throws Throwable;
-
- private native void nativeInitialize();
-
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRendererScheduler.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRendererScheduler.java
deleted file mode 100644
index fd12cceee6..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRendererScheduler.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.mapbox.mapboxsdk.maps.renderer;
-
-import android.support.annotation.Keep;
-
-/**
- * Can be used to schedule work on the map renderer
- * thread or request a render.
- */
-public interface MapRendererScheduler {
-
- @Keep
- void requestRender();
-
- @Keep
- void queueEvent(Runnable runnable);
-
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/EGLConfigChooser.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/EGLConfigChooser.java
deleted file mode 100644
index 178911b0ac..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/EGLConfigChooser.java
+++ /dev/null
@@ -1,328 +0,0 @@
-package com.mapbox.mapboxsdk.maps.renderer.egl;
-
-import android.opengl.GLSurfaceView;
-import android.os.Build;
-import android.support.annotation.NonNull;
-import com.mapbox.mapboxsdk.constants.MapboxConstants;
-import com.mapbox.mapboxsdk.log.Logger;
-
-import javax.microedition.khronos.egl.EGL10;
-import javax.microedition.khronos.egl.EGLConfig;
-import javax.microedition.khronos.egl.EGLDisplay;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import static com.mapbox.mapboxsdk.utils.Compare.compare;
-import static javax.microedition.khronos.egl.EGL10.EGL_ALPHA_MASK_SIZE;
-import static javax.microedition.khronos.egl.EGL10.EGL_ALPHA_SIZE;
-import static javax.microedition.khronos.egl.EGL10.EGL_BLUE_SIZE;
-import static javax.microedition.khronos.egl.EGL10.EGL_BUFFER_SIZE;
-import static javax.microedition.khronos.egl.EGL10.EGL_COLOR_BUFFER_TYPE;
-import static javax.microedition.khronos.egl.EGL10.EGL_CONFIG_CAVEAT;
-import static javax.microedition.khronos.egl.EGL10.EGL_DEPTH_SIZE;
-import static javax.microedition.khronos.egl.EGL10.EGL_GREEN_SIZE;
-import static javax.microedition.khronos.egl.EGL10.EGL_NONE;
-import static javax.microedition.khronos.egl.EGL10.EGL_RED_SIZE;
-import static javax.microedition.khronos.egl.EGL10.EGL_RENDERABLE_TYPE;
-import static javax.microedition.khronos.egl.EGL10.EGL_RGB_BUFFER;
-import static javax.microedition.khronos.egl.EGL10.EGL_SAMPLES;
-import static javax.microedition.khronos.egl.EGL10.EGL_SAMPLE_BUFFERS;
-import static javax.microedition.khronos.egl.EGL10.EGL_STENCIL_SIZE;
-import static javax.microedition.khronos.egl.EGL10.EGL_SURFACE_TYPE;
-import static javax.microedition.khronos.egl.EGL10.EGL_WINDOW_BIT;
-
-/**
- * Selects the right EGLConfig needed for `mapbox-gl-native`
- */
-public class EGLConfigChooser implements GLSurfaceView.EGLConfigChooser {
-
- private static final String TAG = "Mbgl-EGLConfigChooser";
-
- /**
- * Requires API level 17
- *
- * @see android.opengl.EGL14.EGL_CONFORMANT;
- */
- @SuppressWarnings("JavadocReference")
- private static final int EGL_CONFORMANT = 0x3042;
-
- /**
- * Requires API level 17
- *
- * @see android.opengl.EGL14.EGL_OPENGL_ES2_BIT;
- */
- @SuppressWarnings("JavadocReference")
- private static final int EGL_OPENGL_ES2_BIT = 0x0004;
-
- private boolean translucentSurface;
-
- public EGLConfigChooser() {
- this(false);
- }
-
- public EGLConfigChooser(boolean translucentSurface) {
- super();
- this.translucentSurface = translucentSurface;
- }
-
- @Override
- public EGLConfig chooseConfig(@NonNull EGL10 egl, EGLDisplay display) {
- int[] configAttribs = getConfigAttributes();
-
- // Determine number of possible configurations
- int[] numConfigs = getNumberOfConfigurations(egl, display, configAttribs);
- if (numConfigs[0] < 1) {
- Logger.e(TAG, "eglChooseConfig() returned no configs.");
- throw new EGLConfigException("eglChooseConfig() failed");
- }
-
- // Get all possible configurations
- EGLConfig[] possibleConfigurations = getPossibleConfigurations(egl, display, configAttribs, numConfigs);
-
- // Choose best match
- EGLConfig config = chooseBestMatchConfig(egl, display, possibleConfigurations);
- if (config == null) {
- Logger.e(TAG, "No config chosen");
- throw new EGLConfigException("No config chosen");
- }
-
- return config;
- }
-
- @NonNull
- private int[] getNumberOfConfigurations(EGL10 egl, EGLDisplay display, int[] configAttributes) {
- int[] numConfigs = new int[1];
- if (!egl.eglChooseConfig(display, configAttributes, null, 0, numConfigs)) {
- Logger.e(TAG, String.format(
- MapboxConstants.MAPBOX_LOCALE, "eglChooseConfig(NULL) returned error %d", egl.eglGetError())
- );
- throw new EGLConfigException("eglChooseConfig() failed");
- }
- return numConfigs;
- }
-
- @NonNull
- private EGLConfig[] getPossibleConfigurations(EGL10 egl, EGLDisplay display,
- int[] configAttributes, int[] numConfigs) {
- EGLConfig[] configs = new EGLConfig[numConfigs[0]];
- if (!egl.eglChooseConfig(display, configAttributes, configs, numConfigs[0], numConfigs)) {
- Logger.e(TAG, String.format(
- MapboxConstants.MAPBOX_LOCALE, "eglChooseConfig() returned error %d", egl.eglGetError())
- );
- throw new EGLConfigException("eglChooseConfig() failed");
- }
- return configs;
- }
-
- // Quality
- enum BufferFormat {
- Format16Bit(3),
- Format32BitNoAlpha(1),
- Format32BitAlpha(2),
- Format24Bit(0),
- Unknown(4);
-
- int value;
-
- BufferFormat(int value) {
- this.value = value;
- }
- }
-
- enum DepthStencilFormat {
- Format16Depth8Stencil(1),
- Format24Depth8Stencil(0);
-
- int value;
-
- DepthStencilFormat(int value) {
- this.value = value;
- }
- }
-
- private EGLConfig chooseBestMatchConfig(@NonNull EGL10 egl, EGLDisplay display, EGLConfig[] configs) {
- class Config implements Comparable<Config> {
- private final BufferFormat bufferFormat;
- private final DepthStencilFormat depthStencilFormat;
- private final boolean isNotConformant;
- private final boolean isCaveat;
- private final int index;
- private final EGLConfig config;
-
- public Config(BufferFormat bufferFormat, DepthStencilFormat depthStencilFormat,
- boolean isNotConformant, boolean isCaveat, int index, EGLConfig config) {
- this.bufferFormat = bufferFormat;
- this.depthStencilFormat = depthStencilFormat;
- this.isNotConformant = isNotConformant;
- this.isCaveat = isCaveat;
- this.index = index;
- this.config = config;
- }
-
-
- @Override
- public int compareTo(@NonNull Config other) {
- int i = compare(bufferFormat.value, other.bufferFormat.value);
- if (i != 0) {
- return i;
- }
-
- i = compare(depthStencilFormat.value, other.depthStencilFormat.value);
- if (i != 0) {
- return i;
- }
-
- i = compare(isNotConformant, other.isNotConformant);
- if (i != 0) {
- return i;
- }
-
- i = compare(isCaveat, other.isCaveat);
- if (i != 0) {
- return i;
- }
-
- i = compare(index, other.index);
- if (i != 0) {
- return i;
- }
-
- return 0;
- }
- }
-
- List<Config> matches = new ArrayList<>();
-
- int i = 0;
- for (EGLConfig config : configs) {
- i++;
-
- int caveat = getConfigAttr(egl, display, config, EGL_CONFIG_CAVEAT);
- int conformant = getConfigAttr(egl, display, config, EGL_CONFORMANT);
- int bits = getConfigAttr(egl, display, config, EGL_BUFFER_SIZE);
- int red = getConfigAttr(egl, display, config, EGL_RED_SIZE);
- int green = getConfigAttr(egl, display, config, EGL_GREEN_SIZE);
- int blue = getConfigAttr(egl, display, config, EGL_BLUE_SIZE);
- int alpha = getConfigAttr(egl, display, config, EGL_ALPHA_SIZE);
- int alphaMask = getConfigAttr(egl, display, config, EGL_ALPHA_MASK_SIZE);
- int depth = getConfigAttr(egl, display, config, EGL_DEPTH_SIZE);
- int stencil = getConfigAttr(egl, display, config, EGL_STENCIL_SIZE);
- int sampleBuffers = getConfigAttr(egl, display, config, EGL_SAMPLE_BUFFERS);
- int samples = getConfigAttr(egl, display, config, EGL_SAMPLES);
-
- boolean configOk = (depth == 24) || (depth == 16);
- configOk &= stencil == 8;
- configOk &= sampleBuffers == 0;
- configOk &= samples == 0;
-
- // Filter our configs first for depth, stencil and anti-aliasing
- if (configOk) {
- // Work out the config's buffer format
- BufferFormat bufferFormat;
- if ((bits == 16) && (red == 5) && (green == 6) && (blue == 5) && (alpha == 0)) {
- bufferFormat = BufferFormat.Format16Bit;
- } else if ((bits == 32) && (red == 8) && (green == 8) && (blue == 8) && (alpha == 0)) {
- bufferFormat = BufferFormat.Format32BitNoAlpha;
- } else if ((bits == 32) && (red == 8) && (green == 8) && (blue == 8) && (alpha == 8)) {
- bufferFormat = BufferFormat.Format32BitAlpha;
- } else if ((bits == 24) && (red == 8) && (green == 8) && (blue == 8) && (alpha == 0)) {
- bufferFormat = BufferFormat.Format24Bit;
- } else {
- bufferFormat = BufferFormat.Unknown;
- }
-
- // Work out the config's depth stencil format
- DepthStencilFormat depthStencilFormat;
- if ((depth == 16) && (stencil == 8)) {
- depthStencilFormat = DepthStencilFormat.Format16Depth8Stencil;
- } else {
- depthStencilFormat = DepthStencilFormat.Format24Depth8Stencil;
- }
-
- boolean isNotConformant = (conformant & EGL_OPENGL_ES2_BIT) != EGL_OPENGL_ES2_BIT;
- boolean isCaveat = caveat != EGL_NONE;
-
- // Ignore formats we don't recognise
- if (bufferFormat != BufferFormat.Unknown) {
- matches.add(new Config(bufferFormat, depthStencilFormat, isNotConformant, isCaveat, i, config));
- }
- }
-
- }
-
- // Sort
- Collections.sort(matches);
-
- if (matches.size() == 0) {
- throw new EGLConfigException("No matching configurations after filtering");
- }
-
- Config bestMatch = matches.get(0);
-
- if (bestMatch.isCaveat) {
- Logger.w(TAG, "Chosen config has a caveat.");
- }
-
- if (bestMatch.isNotConformant) {
- Logger.w(TAG, "Chosen config is not conformant.");
- }
-
- return bestMatch.config;
- }
-
- private int getConfigAttr(EGL10 egl, EGLDisplay display, EGLConfig config, int attributeName) {
- int[] attributevalue = new int[1];
- if (!egl.eglGetConfigAttrib(display, config, attributeName, attributevalue)) {
- Logger.e(TAG, String.format(
- MapboxConstants.MAPBOX_LOCALE, "eglGetConfigAttrib(%d) returned error %d", attributeName, egl.eglGetError())
- );
- throw new EGLConfigException("eglGetConfigAttrib() failed");
- }
- return attributevalue[0];
- }
-
- private int[] getConfigAttributes() {
- boolean emulator = inEmulator() || inGenymotion();
- Logger.i(TAG, String.format("In emulator: %s", emulator));
-
- // Get all configs at least RGB 565 with 16 depth and 8 stencil
- return new int[] {
- EGL_CONFIG_CAVEAT, EGL_NONE,
- EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
- EGL_BUFFER_SIZE, 16,
- EGL_RED_SIZE, 5,
- EGL_GREEN_SIZE, 6,
- EGL_BLUE_SIZE, 5,
- EGL_ALPHA_SIZE, translucentSurface ? 8 : 0,
- EGL_DEPTH_SIZE, 16,
- EGL_STENCIL_SIZE, 8,
- (emulator ? EGL_NONE : EGL_CONFORMANT), EGL_OPENGL_ES2_BIT,
- (emulator ? EGL_NONE : EGL_COLOR_BUFFER_TYPE), EGL_RGB_BUFFER,
- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
- EGL_NONE
- };
- }
-
- /**
- * Detect if we are in emulator.
- */
- private boolean inEmulator() {
- return Build.FINGERPRINT.startsWith("generic")
- || Build.FINGERPRINT.startsWith("unknown")
- || Build.MODEL.contains("google_sdk")
- || Build.MODEL.contains("Emulator")
- || Build.MODEL.contains("Android SDK built for x86")
- || (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))
- || "google_sdk".equals(Build.PRODUCT)
- || System.getProperty("ro.kernel.qemu") != null;
- }
-
- /**
- * Detect if we are in genymotion
- */
- private boolean inGenymotion() {
- return Build.MANUFACTURER.contains("Genymotion");
- }
-
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/EGLConfigException.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/EGLConfigException.java
deleted file mode 100644
index d5a1c9951f..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/EGLConfigException.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.mapbox.mapboxsdk.maps.renderer.egl;
-
-/**
- * Used for EGL configuration exceptions
- */
-public class EGLConfigException extends RuntimeException {
- public EGLConfigException() {
- }
-
- public EGLConfigException(String message) {
- super(message);
- }
-
- public EGLConfigException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public EGLConfigException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/package-info.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/package-info.java
deleted file mode 100644
index b14b302652..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Contains the Mapbox Maps Android EGL API classes.
- */
-package com.mapbox.mapboxsdk.maps.renderer.egl;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/GLSurfaceViewMapRenderer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/GLSurfaceViewMapRenderer.java
deleted file mode 100644
index 2d0c0ed69b..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/GLSurfaceViewMapRenderer.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package com.mapbox.mapboxsdk.maps.renderer.glsurfaceview;
-
-import android.content.Context;
-import android.opengl.GLSurfaceView;
-import android.support.annotation.NonNull;
-
-import com.mapbox.mapboxsdk.maps.renderer.MapRenderer;
-import com.mapbox.mapboxsdk.maps.renderer.egl.EGLConfigChooser;
-
-import javax.microedition.khronos.egl.EGLConfig;
-import javax.microedition.khronos.opengles.GL10;
-
-import static android.opengl.GLSurfaceView.RENDERMODE_WHEN_DIRTY;
-
-/**
- * The {@link GLSurfaceViewMapRenderer} encapsulates the GL thread and
- * {@link GLSurfaceView} specifics to render the map.
- *
- * @see MapRenderer
- */
-public class GLSurfaceViewMapRenderer extends MapRenderer implements GLSurfaceView.Renderer {
-
- @NonNull
- private final MapboxGLSurfaceView glSurfaceView;
-
- public GLSurfaceViewMapRenderer(Context context,
- MapboxGLSurfaceView glSurfaceView,
- String localIdeographFontFamily) {
- super(context, localIdeographFontFamily);
- this.glSurfaceView = glSurfaceView;
- glSurfaceView.setEGLContextClientVersion(2);
- glSurfaceView.setEGLConfigChooser(new EGLConfigChooser());
- glSurfaceView.setRenderer(this);
- glSurfaceView.setRenderMode(RENDERMODE_WHEN_DIRTY);
- glSurfaceView.setPreserveEGLContextOnPause(true);
- glSurfaceView.setDetachedListener(new MapboxGLSurfaceView.OnGLSurfaceViewDetachedListener() {
- @Override
- public void onGLSurfaceViewDetached() {
- // because the GL thread is destroyed when the view is detached from window,
- // we need to ensure releasing the native renderer as well.
- // This avoids releasing it only when the view is being recreated, which is already on a new GL thread,
- // and leads to JNI crashes like https://github.com/mapbox/mapbox-gl-native/issues/14618
- nativeReset();
- }
- });
- }
-
- @Override
- public void onStop() {
- glSurfaceView.onPause();
- }
-
- @Override
- public void onPause() {
- super.onPause();
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- }
-
- @Override
- public void onStart() {
- glSurfaceView.onResume();
- }
-
- @Override
- public void onResume() {
- super.onResume();
- }
-
- @Override
- public void onSurfaceCreated(GL10 gl, EGLConfig config) {
- super.onSurfaceCreated(gl, config);
- }
-
- @Override
- protected void onSurfaceDestroyed() {
- super.onSurfaceDestroyed();
- }
-
- @Override
- public void onSurfaceChanged(GL10 gl, int width, int height) {
- super.onSurfaceChanged(gl, width, height);
- }
-
- @Override
- public void onDrawFrame(GL10 gl) {
- super.onDrawFrame(gl);
- }
-
- /**
- * May be called from any thread.
- * <p>
- * Called from the renderer frontend to schedule a render.
- */
- @Override
- public void requestRender() {
- glSurfaceView.requestRender();
- }
-
- /**
- * May be called from any thread.
- * <p>
- * Schedules work to be performed on the MapRenderer thread.
- *
- * @param runnable the runnable to execute
- */
- @Override
- public void queueEvent(Runnable runnable) {
- glSurfaceView.queueEvent(runnable);
- }
-
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/MapboxGLSurfaceView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/MapboxGLSurfaceView.java
deleted file mode 100644
index ccdbc58220..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/MapboxGLSurfaceView.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package com.mapbox.mapboxsdk.maps.renderer.glsurfaceview;
-
-import android.content.Context;
-import android.opengl.GLSurfaceView;
-import android.support.annotation.NonNull;
-import android.util.AttributeSet;
-
-/**
- * {@link GLSurfaceView} extension that notifies a listener when the view is detached from window,
- * which is the point of destruction of the GL thread.
- */
-public class MapboxGLSurfaceView extends GLSurfaceView {
-
- private OnGLSurfaceViewDetachedListener detachedListener;
-
- public MapboxGLSurfaceView(Context context) {
- super(context);
- }
-
- public MapboxGLSurfaceView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- @Override
- protected void onDetachedFromWindow() {
- if (detachedListener != null) {
- detachedListener.onGLSurfaceViewDetached();
- }
- super.onDetachedFromWindow();
- }
-
- /**
- * Set a listener that gets notified when the view is detached from window.
- *
- * @param detachedListener listener
- */
- public void setDetachedListener(@NonNull OnGLSurfaceViewDetachedListener detachedListener) {
- if (this.detachedListener != null) {
- throw new IllegalArgumentException("Detached from window listener has been already set.");
- }
- this.detachedListener = detachedListener;
- }
-
- /**
- * Listener interface that notifies when a {@link MapboxGLSurfaceView} is detached from window.
- */
- public interface OnGLSurfaceViewDetachedListener {
-
- /**
- * Called when a {@link MapboxGLSurfaceView} is detached from window.
- */
- void onGLSurfaceViewDetached();
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/package-info.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/package-info.java
deleted file mode 100644
index aefcffef42..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Contains the Mapbox Maps Android GLSurfaceView API classes.
- */
-package com.mapbox.mapboxsdk.maps.renderer.glsurfaceview;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/package-info.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/package-info.java
deleted file mode 100644
index f5d8021ea1..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Contains the Mapbox Maps Android Renderer API classes.
- */
-package com.mapbox.mapboxsdk.maps.renderer;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewMapRenderer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewMapRenderer.java
deleted file mode 100644
index 46e6463fe8..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewMapRenderer.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package com.mapbox.mapboxsdk.maps.renderer.textureview;
-
-import android.content.Context;
-import android.support.annotation.NonNull;
-import android.view.TextureView;
-
-import com.mapbox.mapboxsdk.maps.renderer.MapRenderer;
-
-import javax.microedition.khronos.egl.EGLConfig;
-import javax.microedition.khronos.opengles.GL10;
-
-/**
- * The {@link TextureViewMapRenderer} encapsulates the GL thread and
- * {@link TextureView} specifics to render the map.
- *
- * @see MapRenderer
- */
-public class TextureViewMapRenderer extends MapRenderer {
- private TextureViewRenderThread renderThread;
- private boolean translucentSurface;
-
- /**
- * Create a {@link MapRenderer} for the given {@link TextureView}
- *
- * @param context the current Context
- * @param textureView the TextureView
- * @param localIdeographFontFamily the local font family
- * @param translucentSurface the translucency flag
- */
- public TextureViewMapRenderer(@NonNull Context context,
- @NonNull TextureView textureView,
- String localIdeographFontFamily,
- boolean translucentSurface) {
- super(context, localIdeographFontFamily);
- this.translucentSurface = translucentSurface;
- renderThread = new TextureViewRenderThread(textureView, this);
- renderThread.start();
- }
-
- /**
- * Overridden to provide package access
- */
- @Override
- protected void onSurfaceCreated(GL10 gl, EGLConfig config) {
- super.onSurfaceCreated(gl, config);
- }
-
- /**
- * Overridden to provide package access
- */
- @Override
- protected void onSurfaceChanged(GL10 gl, int width, int height) {
- super.onSurfaceChanged(gl, width, height);
- }
-
- /**
- * Overridden to provide package access
- */
- @Override
- protected void onSurfaceDestroyed() {
- super.onSurfaceDestroyed();
- }
-
- /**
- * Overridden to provide package access
- */
- @Override
- protected void onDrawFrame(GL10 gl) {
- super.onDrawFrame(gl);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void requestRender() {
- renderThread.requestRender();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void queueEvent(Runnable runnable) {
- renderThread.queueEvent(runnable);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onStop() {
- renderThread.onPause();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onStart() {
- renderThread.onResume();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onDestroy() {
- renderThread.onDestroy();
- }
-
- public boolean isTranslucentSurface() {
- return translucentSurface;
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewRenderThread.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewRenderThread.java
deleted file mode 100644
index 205e35641b..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewRenderThread.java
+++ /dev/null
@@ -1,470 +0,0 @@
-package com.mapbox.mapboxsdk.maps.renderer.textureview;
-
-import android.graphics.SurfaceTexture;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.annotation.UiThread;
-import android.view.TextureView;
-
-import com.mapbox.mapboxsdk.log.Logger;
-import com.mapbox.mapboxsdk.maps.renderer.egl.EGLConfigChooser;
-
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-
-import javax.microedition.khronos.egl.EGL10;
-import javax.microedition.khronos.egl.EGL11;
-import javax.microedition.khronos.egl.EGLConfig;
-import javax.microedition.khronos.egl.EGLContext;
-import javax.microedition.khronos.egl.EGLDisplay;
-import javax.microedition.khronos.egl.EGLSurface;
-import javax.microedition.khronos.opengles.GL10;
-
-/**
- * The render thread is responsible for managing the communication between the
- * ui thread and the render thread it creates. Also, the EGL and GL contexts
- * are managed from here.
- */
-class TextureViewRenderThread extends Thread implements TextureView.SurfaceTextureListener {
-
- private static final String TAG = "Mbgl-TextureViewRenderThread";
-
- @NonNull
- private final TextureViewMapRenderer mapRenderer;
- @NonNull
- private final EGLHolder eglHolder;
-
- // Lock used for synchronization
- private final Object lock = new Object();
-
- // Guarded by lock
- private final ArrayList<Runnable> eventQueue = new ArrayList<>();
- @Nullable
- private SurfaceTexture surface;
- private int width;
- private int height;
- private boolean requestRender;
- private boolean sizeChanged;
- private boolean paused;
- private boolean destroyContext;
- private boolean destroySurface;
- private boolean shouldExit;
- private boolean exited;
-
- /**
- * Create a render thread for the given TextureView / Maprenderer combination.
- *
- * @param textureView the TextureView
- * @param mapRenderer the MapRenderer
- */
- @UiThread
- TextureViewRenderThread(@NonNull TextureView textureView, @NonNull TextureViewMapRenderer mapRenderer) {
- textureView.setOpaque(!mapRenderer.isTranslucentSurface());
- textureView.setSurfaceTextureListener(this);
- this.mapRenderer = mapRenderer;
- this.eglHolder = new EGLHolder(new WeakReference<>(textureView), mapRenderer.isTranslucentSurface());
- }
-
- // SurfaceTextureListener methods
-
- @UiThread
- @Override
- public void onSurfaceTextureAvailable(final SurfaceTexture surface, final int width, final int height) {
- synchronized (lock) {
- this.surface = surface;
- this.width = width;
- this.height = height;
- this.requestRender = true;
- lock.notifyAll();
- }
- }
-
- @Override
- @UiThread
- public void onSurfaceTextureSizeChanged(SurfaceTexture surface, final int width, final int height) {
- synchronized (lock) {
- this.width = width;
- this.height = height;
- this.sizeChanged = true;
- this.requestRender = true;
- lock.notifyAll();
- }
- }
-
- @Override
- @UiThread
- public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
- synchronized (lock) {
- this.surface = null;
- this.destroySurface = true;
- this.requestRender = false;
- lock.notifyAll();
- }
- return true;
- }
-
- @Override
- @UiThread
- public void onSurfaceTextureUpdated(SurfaceTexture surface) {
- // Ignored
- }
-
- // MapRenderer delegate methods
-
- /**
- * May be called from any thread
- */
- void requestRender() {
- synchronized (lock) {
- requestRender = true;
- lock.notifyAll();
- }
- }
-
- /**
- * May be called from any thread
- */
- void queueEvent(@NonNull Runnable runnable) {
- if (runnable == null) {
- throw new IllegalArgumentException("runnable must not be null");
- }
- synchronized (lock) {
- eventQueue.add(runnable);
- lock.notifyAll();
- }
- }
-
-
- @UiThread
- void onPause() {
- synchronized (lock) {
- this.paused = true;
- lock.notifyAll();
- }
- }
-
- @UiThread
- void onResume() {
- synchronized (lock) {
- this.paused = false;
- lock.notifyAll();
- }
- }
-
-
- @UiThread
- void onDestroy() {
- synchronized (lock) {
- this.shouldExit = true;
- lock.notifyAll();
-
- // Wait for the thread to exit
- while (!this.exited) {
- try {
- lock.wait();
- } catch (InterruptedException ex) {
- Thread.currentThread().interrupt();
- }
- }
- }
- }
-
- // Thread implementation
-
- @Override
- public void run() {
- try {
-
- while (true) {
- Runnable event = null;
- boolean initializeEGL = false;
- boolean recreateSurface = false;
- int w = -1;
- int h = -1;
-
- // Guarded block
- synchronized (lock) {
- while (true) {
-
- if (shouldExit) {
- return;
- }
-
- // If any events are scheduled, pop one for processing
- if (!eventQueue.isEmpty()) {
- event = eventQueue.remove(0);
- break;
- }
-
- if (destroySurface) {
- eglHolder.destroySurface();
- destroySurface = false;
- break;
- }
-
- if (destroyContext) {
- eglHolder.destroyContext();
- destroyContext = false;
- break;
- }
-
- if (surface != null && !paused && requestRender) {
-
- w = width;
- h = height;
-
- // Initialize EGL if needed
- if (eglHolder.eglContext == EGL10.EGL_NO_CONTEXT) {
- initializeEGL = true;
- break;
- }
-
- // (re-)Initialize EGL Surface if needed
- if (eglHolder.eglSurface == EGL10.EGL_NO_SURFACE) {
- recreateSurface = true;
- break;
- }
-
- // Reset the request render flag now, so we can catch new requests
- // while rendering
- requestRender = false;
-
- // Break the guarded loop and continue to process
- break;
- }
-
-
- // Wait until needed
- lock.wait();
-
- } // end guarded while loop
-
- } // end guarded block
-
- // Run event, if any
- if (event != null) {
- event.run();
- continue;
- }
-
- GL10 gl = eglHolder.createGL();
-
- // Initialize EGL
- if (initializeEGL) {
- eglHolder.prepare();
- synchronized (lock) {
- if (!eglHolder.createSurface()) {
- // Cleanup the surface if one could not be created
- // and wait for another to be ready.
- destroySurface = true;
- continue;
- }
- }
- mapRenderer.onSurfaceCreated(gl, eglHolder.eglConfig);
- mapRenderer.onSurfaceChanged(gl, w, h);
- continue;
- }
-
- // If the surface size has changed inform the map renderer.
- if (recreateSurface) {
- synchronized (lock) {
- eglHolder.createSurface();
- }
- mapRenderer.onSurfaceChanged(gl, w, h);
- continue;
- }
-
- if (sizeChanged) {
- mapRenderer.onSurfaceChanged(gl, w, h);
- sizeChanged = false;
- continue;
- }
-
- // Don't continue without a surface
- if (eglHolder.eglSurface == EGL10.EGL_NO_SURFACE) {
- continue;
- }
-
- // Time to render a frame
- mapRenderer.onDrawFrame(gl);
-
- // Swap and check the result
- int swapError = eglHolder.swap();
- switch (swapError) {
- case EGL10.EGL_SUCCESS:
- break;
- case EGL11.EGL_CONTEXT_LOST:
- Logger.w(TAG, "Context lost. Waiting for re-aquire");
- synchronized (lock) {
- surface = null;
- destroySurface = true;
- destroyContext = true;
- }
- break;
- default:
- Logger.w(TAG, String.format("eglSwapBuffer error: %s. Waiting or new surface", swapError));
- // Probably lost the surface. Clear the current one and
- // wait for a new one to be set
- synchronized (lock) {
- surface = null;
- destroySurface = true;
- }
- }
-
- }
-
- } catch (InterruptedException err) {
- // To be expected
- } finally {
- // Cleanup
- eglHolder.cleanup();
-
- // Signal we're done
- synchronized (lock) {
- this.exited = true;
- lock.notifyAll();
- }
- }
- }
-
- /**
- * Holds the EGL state and offers methods to mutate it.
- */
- private static class EGLHolder {
- private static final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
- private final WeakReference<TextureView> textureViewWeakRef;
- private boolean translucentSurface;
-
- private EGL10 egl;
- @Nullable
- private EGLConfig eglConfig;
- private EGLDisplay eglDisplay = EGL10.EGL_NO_DISPLAY;
- private EGLContext eglContext = EGL10.EGL_NO_CONTEXT;
- private EGLSurface eglSurface = EGL10.EGL_NO_SURFACE;
-
- EGLHolder(WeakReference<TextureView> textureViewWeakRef, boolean translucentSurface) {
- this.textureViewWeakRef = textureViewWeakRef;
- this.translucentSurface = translucentSurface;
- }
-
- void prepare() {
- this.egl = (EGL10) EGLContext.getEGL();
-
- // Only re-initialize display when needed
- if (eglDisplay == EGL10.EGL_NO_DISPLAY) {
- this.eglDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
-
- if (eglDisplay == EGL10.EGL_NO_DISPLAY) {
- throw new RuntimeException("eglGetDisplay failed");
- }
-
- int[] version = new int[2];
- if (!egl.eglInitialize(eglDisplay, version)) {
- throw new RuntimeException("eglInitialize failed");
- }
- }
-
- if (textureViewWeakRef == null) {
- // No texture view present
- eglConfig = null;
- eglContext = EGL10.EGL_NO_CONTEXT;
- } else if (eglContext == EGL10.EGL_NO_CONTEXT) {
- eglConfig = new EGLConfigChooser(translucentSurface).chooseConfig(egl, eglDisplay);
- int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE};
- eglContext = egl.eglCreateContext(eglDisplay, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list);
- }
-
- if (eglContext == EGL10.EGL_NO_CONTEXT) {
- throw new RuntimeException("createContext");
- }
- }
-
- @NonNull
- GL10 createGL() {
- return (GL10) eglContext.getGL();
- }
-
- boolean createSurface() {
- // The window size has changed, so we need to create a new surface.
- destroySurface();
-
- // Create an EGL surface we can render into.
- TextureView view = textureViewWeakRef.get();
- if (view != null) {
- int[] surfaceAttribs = {EGL10.EGL_NONE};
- eglSurface = egl.eglCreateWindowSurface(eglDisplay, eglConfig, view.getSurfaceTexture(), surfaceAttribs);
- } else {
- eglSurface = EGL10.EGL_NO_SURFACE;
- }
-
- if (eglSurface == null || eglSurface == EGL10.EGL_NO_SURFACE) {
- int error = egl.eglGetError();
- if (error == EGL10.EGL_BAD_NATIVE_WINDOW) {
- Logger.e(TAG, "createWindowSurface returned EGL_BAD_NATIVE_WINDOW.");
- }
- return false;
- }
-
- return makeCurrent();
- }
-
- boolean makeCurrent() {
- if (!egl.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) {
- // Could not make the context current, probably because the underlying
- // SurfaceView surface has been destroyed.
- Logger.w(TAG, String.format("eglMakeCurrent: %s", egl.eglGetError()));
- return false;
- }
-
- return true;
- }
-
- int swap() {
- if (!egl.eglSwapBuffers(eglDisplay, eglSurface)) {
- return egl.eglGetError();
- }
- return EGL10.EGL_SUCCESS;
- }
-
- private void destroySurface() {
- if (eglSurface == EGL10.EGL_NO_SURFACE) {
- return;
- }
-
- if (!egl.eglDestroySurface(eglDisplay, eglSurface)) {
- Logger.w(TAG, String.format("Could not destroy egl surface. Display %s, Surface %s", eglDisplay, eglSurface));
- }
-
- eglSurface = EGL10.EGL_NO_SURFACE;
- }
-
- private void destroyContext() {
- if (eglContext == EGL10.EGL_NO_CONTEXT) {
- return;
- }
-
- if (!egl.eglDestroyContext(eglDisplay, eglContext)) {
- Logger.w(TAG, String.format("Could not destroy egl context. Display %s, Context %s", eglDisplay, eglContext));
- }
-
- eglContext = EGL10.EGL_NO_CONTEXT;
- }
-
- private void terminate() {
- if (eglDisplay == EGL10.EGL_NO_DISPLAY) {
- return;
- }
-
- if (!egl.eglTerminate(eglDisplay)) {
- Logger.w(TAG, String.format("Could not terminate egl. Display %s", eglDisplay));
- }
- eglDisplay = EGL10.EGL_NO_DISPLAY;
- }
-
- void cleanup() {
- destroySurface();
- destroyContext();
- terminate();
- }
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/package-info.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/package-info.java
deleted file mode 100644
index d3585d41f9..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Contains the Mapbox Maps Android TextureView API classes.
- */
-package com.mapbox.mapboxsdk.maps.renderer.textureview;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java
deleted file mode 100644
index b593076dc1..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java
+++ /dev/null
@@ -1,179 +0,0 @@
-package com.mapbox.mapboxsdk.maps.widgets;
-
-import android.content.Context;
-import android.graphics.drawable.Drawable;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v4.view.ViewCompat;
-import android.support.v4.view.ViewPropertyAnimatorCompat;
-import android.support.v4.view.ViewPropertyAnimatorListenerAdapter;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-
-import com.mapbox.mapboxsdk.maps.MapboxMap;
-
-/**
- * UI element overlaid on a map to show the map's bearing when it isn't true north (0.0). Tapping
- * the compass resets the bearing to true north and hides the compass.
- * <p>
- * You can change the behaviour of this View during initialisation with
- * {@link com.mapbox.mapboxsdk.maps.MapboxMapOptions}, and xml attributes. While running you can
- * use {@link com.mapbox.mapboxsdk.maps.UiSettings}.
- * </p>
- */
-public final class CompassView extends ImageView implements Runnable {
-
- public static final long TIME_WAIT_IDLE = 500;
- public static final long TIME_MAP_NORTH_ANIMATION = 150;
- private static final long TIME_FADE_ANIMATION = TIME_WAIT_IDLE;
-
- private float rotation = 0.0f;
- private boolean fadeCompassViewFacingNorth = true;
- @Nullable
- private ViewPropertyAnimatorCompat fadeAnimator;
- private MapboxMap.OnCompassAnimationListener compassAnimationListener;
- private boolean isAnimating = false;
-
- public CompassView(@NonNull Context context) {
- super(context);
- initialize(context);
- }
-
- public CompassView(@NonNull Context context, AttributeSet attrs) {
- super(context, attrs);
- initialize(context);
- }
-
- public CompassView(@NonNull Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- initialize(context);
- }
-
- private void initialize(Context context) {
- setEnabled(false);
-
- // Layout params
- float screenDensity = context.getResources().getDisplayMetrics().density;
- ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams((int) (48 * screenDensity), (int) (48 * screenDensity));
- setLayoutParams(lp);
- }
-
- public void injectCompassAnimationListener(@NonNull MapboxMap.OnCompassAnimationListener compassAnimationListener) {
- this.compassAnimationListener = compassAnimationListener;
- }
-
- public void isAnimating(boolean isAnimating) {
- this.isAnimating = isAnimating;
- }
-
- public void resetAnimation() {
- if (fadeAnimator != null) {
- fadeAnimator.cancel();
- }
- fadeAnimator = null;
- }
-
- public boolean isHidden() {
- return fadeCompassViewFacingNorth && isFacingNorth();
- }
-
- public boolean isFacingNorth() {
- // increase range of facing north to more than only 0.0
- return Math.abs(rotation) >= 359.0 || Math.abs(rotation) <= 1.0;
- }
-
- @Override
- public void setEnabled(boolean enabled) {
- super.setEnabled(enabled);
- if (enabled && !isHidden()) {
- resetAnimation();
- setAlpha(1.0f);
- setVisibility(View.VISIBLE);
- update(rotation);
- } else {
- resetAnimation();
- setAlpha(0.0f);
- setVisibility(View.INVISIBLE);
- }
- }
-
- /**
- * Updates the direction of the compass.
- *
- * @param bearing the direction value of the map
- */
- public void update(final double bearing) {
- rotation = (float) bearing;
-
- if (!isEnabled()) {
- return;
- }
-
- if (isHidden()) {
- if (getVisibility() == View.INVISIBLE || fadeAnimator != null) {
- return;
- }
- postDelayed(this, TIME_WAIT_IDLE);
- return;
- } else {
- resetAnimation();
- setAlpha(1.0f);
- setVisibility(View.VISIBLE);
- }
-
- notifyCompassAnimationListenerWhenAnimating();
- setRotation(rotation);
- }
-
- public void fadeCompassViewFacingNorth(boolean compassFadeFacingNorth) {
- fadeCompassViewFacingNorth = compassFadeFacingNorth;
- }
-
- public boolean isFadeCompassViewFacingNorth() {
- return fadeCompassViewFacingNorth;
- }
-
- /**
- * Set the CompassView image.
- *
- * @param compass the drawable to use as compass image
- */
- public void setCompassImage(Drawable compass) {
- setImageDrawable(compass);
- }
-
- /**
- * Get the current configured CompassView image.
- *
- * @return the drawable used as compass image
- */
- public Drawable getCompassImage() {
- return getDrawable();
- }
-
- @Override
- public void run() {
- if (isHidden()) {
- compassAnimationListener.onCompassAnimationFinished();
- resetAnimation();
- setLayerType(View.LAYER_TYPE_HARDWARE, null);
- fadeAnimator = ViewCompat.animate(CompassView.this).alpha(0.0f).setDuration(TIME_FADE_ANIMATION);
- fadeAnimator.setListener(new ViewPropertyAnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(View view) {
- setLayerType(LAYER_TYPE_NONE, null);
- setVisibility(View.INVISIBLE);
- resetAnimation();
- }
- });
- }
- }
-
- private void notifyCompassAnimationListenerWhenAnimating() {
- if (isAnimating) {
- compassAnimationListener.onCompassAnimation();
- }
- }
-}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/package-info.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/package-info.java
deleted file mode 100644
index 5e8d20f069..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Contains the Mapbox Maps Android Widgets API classes.
- */
-package com.mapbox.mapboxsdk.maps.widgets;