diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000000..9828157bcc
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,6 @@
+## 7.0.0
+
+### removed:
+
+* isTelemeryEnbaled from android [#1](https://github.com/mfazekas/maps/pull/1)
+
diff --git a/android/install.md b/android/install.md
index 2ba5b0dbfd..41905a2c52 100644
--- a/android/install.md
+++ b/android/install.md
@@ -46,7 +46,7 @@ Include project, so gradle knows where to find the project
```
include ':mapbox-react-native-mapbox-gl'
-project(':mapbox-react-native-mapbox-gl').projectDir = new File(rootProject.projectDir, '../node_modules/@mapbox/react-native-mapbox-gl/android/rctmgl')
+project(':mapbox-react-native-mapbox-gl').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-mapbox/maps/android/rctmgl')
```
### MainApplication.java
diff --git a/android/rctmgl/build.gradle b/android/rctmgl/build.gradle
index 34acc1db85..9cbd89c096 100644
--- a/android/rctmgl/build.gradle
+++ b/android/rctmgl/build.gradle
@@ -30,8 +30,9 @@ dependencies {
compileOnly "com.facebook.react:react-native:+"
// Mapbox SDK
- implementation 'com.mapbox.mapboxsdk:mapbox-android-services:2.2.9'
- implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:5.5.3@aar'
+
+ implementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:4.6.0'
+ implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:7.3.0'
// Dependencies
implementation "com.android.support:support-vector-drawable:${safeExtGet('supportLibVersion', '28.0.0')}"
@@ -40,6 +41,6 @@ dependencies {
implementation "com.squareup.okhttp3:okhttp:${safeExtGet('okhttpVersion', '3.12.1')}"
// Mapbox plugins
- implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization:0.1.0'
- implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.3.0'
+ implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v7:0.9.0'
+ implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-markerview-v7:0.2.0'
}
diff --git a/android/rctmgl/src/main/AndroidManifest.xml b/android/rctmgl/src/main/AndroidManifest.xml
index 0eaea12981..cdc05e12a9 100644
--- a/android/rctmgl/src/main/AndroidManifest.xml
+++ b/android/rctmgl/src/main/AndroidManifest.xml
@@ -1,5 +1,4 @@
-
diff --git a/android/rctmgl/src/main/java/com/mapbox/rctmgl/RCTMGLPackage.java b/android/rctmgl/src/main/java/com/mapbox/rctmgl/RCTMGLPackage.java
index 29460c1ef4..728b9e4200 100644
--- a/android/rctmgl/src/main/java/com/mapbox/rctmgl/RCTMGLPackage.java
+++ b/android/rctmgl/src/main/java/com/mapbox/rctmgl/RCTMGLPackage.java
@@ -12,6 +12,7 @@
import com.mapbox.rctmgl.components.annotation.RCTMGLCalloutManager;
import com.mapbox.rctmgl.components.annotation.RCTMGLPointAnnotationManager;
+import com.mapbox.rctmgl.components.camera.RCTMGLCameraManager;
import com.mapbox.rctmgl.components.mapview.RCTMGLMapViewManager;
import com.mapbox.rctmgl.components.mapview.RCTMGLAndroidTextureMapViewManager;
import com.mapbox.rctmgl.components.styles.layers.RCTMGLBackgroundLayerManager;
@@ -26,6 +27,7 @@
import com.mapbox.rctmgl.components.styles.sources.RCTMGLRasterSourceManager;
import com.mapbox.rctmgl.components.styles.sources.RCTMGLShapeSourceManager;
import com.mapbox.rctmgl.components.styles.sources.RCTMGLVectorSourceManager;
+import com.mapbox.rctmgl.modules.RCTMGLLocationModule;
import com.mapbox.rctmgl.modules.RCTMGLModule;
import com.mapbox.rctmgl.modules.RCTMGLOfflineModule;
import com.mapbox.rctmgl.modules.RCTMGLSnapshotModule;
@@ -43,6 +45,7 @@ public List createNativeModules(ReactApplicationContext reactAppli
modules.add(new RCTMGLModule(reactApplicationContext));
modules.add(new RCTMGLOfflineModule(reactApplicationContext));
modules.add(new RCTMGLSnapshotModule(reactApplicationContext));
+ modules.add(new RCTMGLLocationModule(reactApplicationContext));
return modules;
}
@@ -57,6 +60,7 @@ public List createViewManagers(ReactApplicationContext reactApplica
List managers = new ArrayList<>();
// components
+ managers.add(new RCTMGLCameraManager(reactApplicationContext));
managers.add(new RCTMGLMapViewManager(reactApplicationContext));
managers.add(new RCTMGLAndroidTextureMapViewManager(reactApplicationContext));
managers.add(new RCTMGLLightManager());
diff --git a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/AbstractEventEmitter.java b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/AbstractEventEmitter.java
index 9af23ffc94..7fa9007449 100644
--- a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/AbstractEventEmitter.java
+++ b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/AbstractEventEmitter.java
@@ -2,11 +2,13 @@
import android.view.ViewGroup;
+import com.facebook.react.ReactApplication;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewGroupManager;
+import com.facebook.react.uimanager.events.RCTEventEmitter;
import java.util.HashMap;
import java.util.Map;
@@ -14,6 +16,7 @@
import javax.annotation.Nullable;
import com.facebook.react.uimanager.events.EventDispatcher;
+import com.mapbox.rctmgl.events.EventEmitter;
import com.mapbox.rctmgl.events.IEvent;
/**
@@ -24,9 +27,11 @@ abstract public class AbstractEventEmitter extends ViewGrou
private static final double BRIDGE_TIMEOUT_MS = 10;
private Map mRateLimitedEvents;
private EventDispatcher mEventDispatcher;
+ private ReactApplicationContext mRCTAppContext;
public AbstractEventEmitter(ReactApplicationContext reactApplicationContext) {
mRateLimitedEvents = new HashMap<>();
+ mRCTAppContext = reactApplicationContext;
}
public void handleEvent(IEvent event) {
@@ -39,6 +44,11 @@ public void handleEvent(IEvent event) {
mRateLimitedEvents.put(eventCacheKey, System.currentTimeMillis());
mEventDispatcher.dispatchEvent(new AbstractEvent(event.getID(), event.getKey(), event.toJSON()));
+
+ RCTEventEmitter emitter = EventEmitter.getViewEmitter(mRCTAppContext);
+ if (emitter != null) {
+ emitter.receiveEvent(event.getID(), event.getKey(), event.toJSON());
+ }
}
@Override
diff --git a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/RCTMGLPointAnnotation.java b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/RCTMGLPointAnnotation.java
index 8628566527..12e3b3c967 100644
--- a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/RCTMGLPointAnnotation.java
+++ b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/RCTMGLPointAnnotation.java
@@ -5,19 +5,17 @@
import android.view.MotionEvent;
import android.view.View;
-import com.facebook.react.bridge.ReactApplicationContext;
-import com.facebook.react.bridge.ReactContext;
-import com.facebook.react.uimanager.UIManagerModule;
-import com.mapbox.mapboxsdk.annotations.MarkerView;
+import com.mapbox.geojson.Point;
+import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
+import com.mapbox.mapboxsdk.plugins.markerview.MarkerView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.rctmgl.components.AbstractMapFeature;
import com.mapbox.rctmgl.components.mapview.RCTMGLMapView;
import com.mapbox.rctmgl.events.PointAnnotationClickEvent;
import com.mapbox.rctmgl.events.constants.EventTypes;
import com.mapbox.rctmgl.utils.GeoJSONUtils;
-import com.mapbox.services.commons.geojson.Point;
import java.util.Arrays;
import java.util.List;
@@ -28,7 +26,7 @@
public class RCTMGLPointAnnotation extends AbstractMapFeature {
private RCTMGLPointAnnotationManager mManager;
- private MarkerView mAnnotation;
+ private Marker mAnnotation;
private MapboxMap mMap;
private RCTMGLMapView mMapView;
@@ -141,7 +139,9 @@ public void setAnchor(float x, float y) {
mAnchor = Arrays.asList(x, y);
if (mAnnotation != null) {
- mAnnotation.setAnchor(x, y);
+ mAnnotation.setRightOffsetPixels((int)x);
+ mAnnotation.setTopOffsetPixels((int)y);
+ /* FMTODO mAnnotation.setAnchor(x, y); */
}
}
@@ -157,7 +157,7 @@ public void setReactSelected(boolean isSelected) {
}
}
- public MarkerView getMarker() {
+ public Marker getMarker() {
return mAnnotation;
}
@@ -179,7 +179,10 @@ public void makeMarker() {
mAnnotation = mMap.addMarker(buildOptions());
if (mAnchor != null && mAnchor.size() == 2) {
- mAnnotation.setAnchor(mAnchor.get(0), mAnchor.get(1));
+
+ //mAnnotation.setAnchor(mAnchor.get(0), mAnchor.get(1));
+ mAnnotation.setRightOffsetPixels((int)mAnchor.get(0).floatValue());
+ mAnnotation.setTopOffsetPixels((int)mAnchor.get(1).floatValue());
}
final RCTMGLPointAnnotation self = this;
@@ -188,6 +191,7 @@ public void makeMarker() {
}
}
+
private RCTMGLPointAnnotationOptions buildOptions() {
RCTMGLPointAnnotationOptions options = new RCTMGLPointAnnotationOptions();
options.annotationID(mID);
@@ -212,6 +216,25 @@ private PointF getScreenPosition() {
return new PointF((float) loc[0], (float) loc[1]);
}
+ public static class CustomMarker extends Marker {
+ private String mAnnotationID;
+ private RCTMGLPointAnnotationOptions mOptions;
+
+ public CustomMarker(String annotationID, RCTMGLPointAnnotationOptions options) {
+ super(options);
+ mOptions = options;
+ mAnnotationID = annotationID;
+ }
+
+ public String getAnnotationID() {
+ return mAnnotationID;
+ }
+
+ public boolean isDefaultIcon() {
+ return !mOptions.getHasChildren();
+ }
+ }
+/*
public static class CustomView extends MarkerView {
private String mAnnotationID;
private RCTMGLPointAnnotationOptions mOptions;
@@ -229,5 +252,5 @@ public String getAnnotationID() {
public boolean isDefaultIcon() {
return !mOptions.getHasChildren();
}
- }
+ } */
}
diff --git a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/RCTMGLPointAnnotationAdapter.java b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/RCTMGLPointAnnotationAdapter.java
index 61ce059219..fafb835bc2 100644
--- a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/RCTMGLPointAnnotationAdapter.java
+++ b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/RCTMGLPointAnnotationAdapter.java
@@ -22,19 +22,20 @@
* Created by nickitaliano on 9/27/17.
*/
-public class RCTMGLPointAnnotationAdapter extends MapboxMap.MarkerViewAdapter {
+public class RCTMGLPointAnnotationAdapter /* extends MapboxMap.MarkerViewAdapter */ {
+ /*
private RCTMGLMapView mMapView;
private LayoutInflater mInflater;
public RCTMGLPointAnnotationAdapter(RCTMGLMapView mapView, Context context) {
- super(context);
+ super(context, RCTMGLPointAnnotation.CustomMarker.class);
mMapView = mapView;
mInflater = LayoutInflater.from(context);
}
@Nullable
@Override
- public View getView(@NonNull RCTMGLPointAnnotation.CustomView customAnnotationView, @Nullable View convertView, @NonNull ViewGroup parent) {
+ public View getView(@NonNull RCTMGLPointAnnotation.CustomMarker customAnnotationView, @Nullable View convertView, @NonNull ViewGroup parent) {
final RCTMGLPointAnnotation pointAnnotation = mMapView.getPointAnnotationByID(customAnnotationView.getAnnotationID());
if (pointAnnotation == null) {
@@ -97,5 +98,5 @@ private float getZIndex(RCTMGLPointAnnotation pointAnnotation) {
private static class ViewHolder {
ImageView imageView;
LinearLayout customLayout;
- }
+ }*/
}
diff --git a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/RCTMGLPointAnnotationOptions.java b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/RCTMGLPointAnnotationOptions.java
index 0b024d3c22..706b39fd52 100644
--- a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/RCTMGLPointAnnotationOptions.java
+++ b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/annotation/RCTMGLPointAnnotationOptions.java
@@ -4,7 +4,8 @@
import android.os.Parcel;
import android.os.Parcelable;
-import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions;
+// import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions;
+import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
import com.mapbox.mapboxsdk.annotations.Icon;
import com.mapbox.mapboxsdk.annotations.IconFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
@@ -13,7 +14,7 @@
* Created by nickitaliano on 9/27/17.
*/
-public class RCTMGLPointAnnotationOptions extends BaseMarkerViewOptions {
+public class RCTMGLPointAnnotationOptions extends BaseMarkerOptions {
private String mAnnotationID;
private boolean mHasChildren;
@@ -23,12 +24,12 @@ protected RCTMGLPointAnnotationOptions(Parcel in) {
position((LatLng) in.readParcelable(LatLng.class.getClassLoader()));
snippet(in.readString());
title(in.readString());
- flat(in.readByte() != 0);
+ /* flat(in.readByte() != 0); */
anchor(in.readFloat(), in.readFloat());
- infoWindowAnchor(in.readFloat(), in.readFloat());
+ /* infoWindowAnchor(in.readFloat(), in.readFloat());
rotation(in.readFloat());
visible(in.readByte() != 0);
- alpha(in.readFloat());
+ alpha(in.readFloat()); */
if (in.readByte() != 0) {
// this means we have an icon
String iconId = in.readString();
@@ -46,8 +47,8 @@ public RCTMGLPointAnnotationOptions getThis() {
}
@Override
- public RCTMGLPointAnnotation.CustomView getMarker() {
- return new RCTMGLPointAnnotation.CustomView(getAnnotationID(), this);
+ public RCTMGLPointAnnotation.CustomMarker getMarker() {
+ return new RCTMGLPointAnnotation.CustomMarker(getAnnotationID(), this);
}
@Override
@@ -57,22 +58,29 @@ public int describeContents() {
@Override
public void writeToParcel(Parcel out, int flags) {
- out.writeParcelable(getPosition(), flags);
- out.writeString(getSnippet());
- out.writeString(getTitle());
+ out.writeParcelable(position, flags);
+ out.writeString(snippet);
+ out.writeString(title);
+ /*
out.writeByte((byte) (isFlat() ? 1 : 0));
+ */
+ /*
out.writeFloat(getAnchorU());
out.writeFloat(getAnchorV());
+
out.writeFloat(getInfoWindowAnchorU());
out.writeFloat(getInfoWindowAnchorV());
out.writeFloat(getRotation());
+ */
+/*
out.writeByte((byte) (isVisible() ? 1 : 0));
out.writeFloat(alpha);
- Icon icon = getIcon();
+ */
+ Icon icon = this.icon;
out.writeByte((byte) (icon != null ? 1 : 0));
if (icon != null) {
- out.writeString(getIcon().getId());
- out.writeParcelable(getIcon().getBitmap(), flags);
+ out.writeString(this.icon.getId());
+ out.writeParcelable(this.icon.getBitmap(), flags);
}
out.writeString(getAnnotationID());
out.writeByte((byte) (getHasChildren() ? 1 : 0));
@@ -96,6 +104,11 @@ public boolean getHasChildren() {
return mHasChildren;
}
+ public RCTMGLPointAnnotationOptions anchor(float x, float y) {
+ // TODO
+ return this;
+ }
+
public static final Parcelable.Creator CREATOR =
new Parcelable.Creator() {
@Override
diff --git a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/CameraStop.java b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/CameraStop.java
index c60da0c045..d6fde76f9c 100644
--- a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/CameraStop.java
+++ b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/CameraStop.java
@@ -5,6 +5,8 @@
import android.util.DisplayMetrics;
import com.facebook.react.bridge.ReadableMap;
+import com.mapbox.geojson.FeatureCollection;
+import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdate;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
@@ -13,8 +15,6 @@
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.rctmgl.components.camera.constants.CameraMode;
import com.mapbox.rctmgl.utils.GeoJSONUtils;
-import com.mapbox.services.commons.geojson.FeatureCollection;
-import com.mapbox.services.commons.geojson.Point;
/**
* Created by nickitaliano on 9/5/17.
@@ -74,11 +74,11 @@ public void setMode(@CameraMode.Mode int mode) {
mMode = mode;
}
- public CameraUpdateItem toCameraUpdate() {
+ public CameraUpdateItem toCameraUpdate(MapboxMap map) {
if (mBounds != null) {
CameraUpdate update = CameraUpdateFactory.newLatLngBounds(mBounds, mBoundsPaddingLeft,
mBooundsPaddingTop, mBoundsPaddingRight, mBoundsPaddingBottom);
- return new CameraUpdateItem(update, mDuration, mCallback, CameraMode.FLIGHT);
+ return new CameraUpdateItem(map, update, mDuration, mCallback, CameraMode.FLIGHT);
}
CameraPosition.Builder builder = new CameraPosition.Builder();
@@ -99,7 +99,7 @@ public CameraUpdateItem toCameraUpdate() {
builder.target(mLatLng);
}
- return new CameraUpdateItem(CameraUpdateFactory.newCameraPosition(builder.build()), mDuration, mCallback, mMode);
+ return new CameraUpdateItem(map, CameraUpdateFactory.newCameraPosition(builder.build()), mDuration, mCallback, mMode);
}
public static CameraStop fromReadableMap(Context context, @NonNull ReadableMap readableMap, MapboxMap.CancelableCallback callback) {
diff --git a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/CameraUpdateItem.java b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/CameraUpdateItem.java
index 2d8d5f4dd4..0fb250f3db 100644
--- a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/CameraUpdateItem.java
+++ b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/CameraUpdateItem.java
@@ -1,48 +1,69 @@
package com.mapbox.rctmgl.components.camera;
+import android.support.annotation.NonNull;
+
import com.mapbox.mapboxsdk.camera.CameraUpdate;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.rctmgl.components.camera.constants.CameraMode;
+import java.lang.ref.WeakReference;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.concurrent.FutureTask;
+import java.util.concurrent.RunnableFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
/**
* Created by nickitaliano on 9/5/17.
*/
-public class CameraUpdateItem {
+public class CameraUpdateItem implements RunnableFuture {
private int mDuration;
private MapboxMap.CancelableCallback mCallback;
private CameraUpdate mCameraUpdate;
private int mCameraMode;
- public interface OnCameraCompleteListener {
- void onComplete();
- }
+ private boolean isCameraActionFinished;
+ private boolean isCameraActionCancelled;
- public CameraUpdateItem(CameraUpdate update, int duration, MapboxMap.CancelableCallback callback, @CameraMode.Mode int cameraMode) {
+ private WeakReference mMap;
+
+ public CameraUpdateItem(MapboxMap map, CameraUpdate update, int duration, MapboxMap.CancelableCallback callback, @CameraMode.Mode int cameraMode) {
mCameraUpdate = update;
mDuration = duration;
mCallback = callback;
mCameraMode = cameraMode;
+ mMap = new WeakReference<>(map);
}
public int getDuration() {
return mDuration;
}
- public void execute(MapboxMap map, final OnCameraCompleteListener listener) {
+ @Override
+ public void run() {
final MapboxMap.CancelableCallback callback = new MapboxMap.CancelableCallback() {
@Override
public void onCancel() {
- handleCallbackResponse(listener, true);
+ handleCallbackResponse(true);
}
@Override
public void onFinish() {
- handleCallbackResponse(listener, false);
+ handleCallbackResponse(false);
}
};
- if (mCameraMode == CameraMode.FLIGHT) {
+ MapboxMap map = mMap.get();
+ if (map == null) {
+ isCameraActionCancelled = true;
+ return;
+ }
+
+ if (mCameraMode == CameraMode.FLIGHT && mDuration > 0) {
map.animateCamera(mCameraUpdate, mDuration, callback);
} else if (mCameraMode == CameraMode.EASE) {
map.easeCamera(mCameraUpdate, mDuration, callback);
@@ -51,13 +72,39 @@ public void onFinish() {
}
}
- private void handleCallbackResponse(OnCameraCompleteListener listener, boolean isCancel) {
- listener.onComplete();
+ @Override
+ public boolean cancel(boolean mayInterruptIfRunning) {
+ return false;
+ }
+ @Override
+ public boolean isCancelled() {
+ return isCameraActionCancelled;
+ }
+
+ @Override
+ public boolean isDone() {
+ return isCameraActionFinished;
+ }
+
+ @Override
+ public Void get() throws InterruptedException, ExecutionException {
+ return null;
+ }
+
+ @Override
+ public Void get(long timeout, @NonNull TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
+ return null;
+ }
+
+ private void handleCallbackResponse(boolean isCancel) {
if (mCallback == null) {
return;
}
+ isCameraActionCancelled = isCancel;
+ isCameraActionFinished = !isCancel;
+
if (isCancel) {
mCallback.onCancel();
} else {
diff --git a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/CameraUpdateQueue.java b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/CameraUpdateQueue.java
index 0d9055a9d6..e9799ac169 100644
--- a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/CameraUpdateQueue.java
+++ b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/CameraUpdateQueue.java
@@ -2,9 +2,14 @@
import com.mapbox.mapboxsdk.maps.MapboxMap;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
+import java.util.List;
import java.util.Queue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.FutureTask;
/**
* Created by nickitaliano on 9/5/17.
@@ -12,6 +17,7 @@
public class CameraUpdateQueue {
private Queue mQueue;
+
private OnCompleteAllListener mCompleteListener;
public interface OnCompleteAllListener {
@@ -35,16 +41,17 @@ public boolean isEmpty() {
}
public void flush() {
- while (!mQueue.isEmpty()) {
+ while (mQueue.size() > 0) {
mQueue.remove();
}
+ mQueue = new LinkedList<>();
}
public void setOnCompleteAllListener(OnCompleteAllListener listener) {
mCompleteListener = listener;
}
- public void execute(final MapboxMap map) {
+ public void execute(MapboxMap map) {
if (mQueue.isEmpty()) {
if (mCompleteListener != null) {
mCompleteListener.onCompleteAll();
@@ -57,12 +64,8 @@ public void execute(final MapboxMap map) {
return;
}
- final CameraUpdateItem item = stop.toCameraUpdate();
- item.execute(map, new CameraUpdateItem.OnCameraCompleteListener() {
- @Override
- public void onComplete() {
- execute(map);
- }
- });
+ CameraUpdateItem item = stop.toCameraUpdate(map);
+ item.run();
+ execute(map);
}
}
diff --git a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/RCTMGLCamera.java b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/RCTMGLCamera.java
new file mode 100644
index 0000000000..aa56cd2fcb
--- /dev/null
+++ b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/RCTMGLCamera.java
@@ -0,0 +1,464 @@
+package com.mapbox.rctmgl.components.camera;
+
+import android.content.Context;
+import android.location.Location;
+
+import com.mapbox.mapboxsdk.camera.CameraPosition;
+import com.mapbox.mapboxsdk.camera.CameraUpdate;
+import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
+import com.mapbox.mapboxsdk.geometry.LatLng;
+import com.mapbox.mapboxsdk.geometry.VisibleRegion;
+import com.mapbox.mapboxsdk.location.modes.CameraMode;
+import com.mapbox.mapboxsdk.location.modes.RenderMode;
+import com.mapbox.mapboxsdk.maps.MapboxMap;
+import com.mapbox.mapboxsdk.maps.Style;
+import com.mapbox.mapboxsdk.location.LocationComponent;
+import com.mapbox.mapboxsdk.location.LocationComponentOptions;
+import com.mapbox.mapboxsdk.location.LocationComponentActivationOptions;
+// import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin;
+import com.mapbox.mapboxsdk.style.layers.Layer;
+import com.mapbox.mapboxsdk.style.layers.Property;
+import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
+import com.mapbox.rctmgl.components.AbstractMapFeature;
+import com.mapbox.rctmgl.components.mapview.RCTMGLMapView;
+import com.mapbox.rctmgl.events.IEvent;
+import com.mapbox.rctmgl.events.MapUserTrackingModeEvent;
+import com.mapbox.rctmgl.events.MapChangeEvent;
+import com.mapbox.rctmgl.location.LocationManager;
+import com.mapbox.rctmgl.location.UserLocation;
+import com.mapbox.rctmgl.location.UserLocationLayerConstants;
+import com.mapbox.rctmgl.location.UserLocationVerticalAlignment;
+import com.mapbox.rctmgl.location.UserTrackingMode;
+import com.mapbox.rctmgl.location.UserTrackingState;
+import com.mapbox.rctmgl.utils.GeoJSONUtils;
+
+import com.mapbox.mapboxsdk.R;
+
+import com.mapbox.rctmgl.events.constants.EventTypes;
+
+import com.facebook.react.bridge.WritableMap;
+import com.facebook.react.bridge.WritableNativeMap;
+
+import com.mapbox.geojson.Point;
+
+import com.mapbox.android.core.permissions.PermissionsManager;
+
+import android.support.annotation.NonNull;
+
+public class RCTMGLCamera extends AbstractMapFeature {
+ private RCTMGLCameraManager mManager;
+ private RCTMGLMapView mMapView;
+
+ private boolean hasSentFirstRegion = false;
+
+ private CameraStop mCameraStop;
+ private CameraUpdateQueue mCameraUpdateQueue;
+
+ private LocationComponent mLocationComponent;
+
+ private int mUserTrackingMode;
+ private int mUserTrackingState = UserTrackingState.POSSIBLE;
+ private int mUserLocationVerticalAlignment = UserLocationVerticalAlignment.CENTER;
+
+ public static final int USER_LOCATION_CAMERA_MOVE_DURATION = 1000;
+
+ private LocationManager mLocationManager;
+ private UserLocation mUserLocation;
+ private boolean mShowUserLocation;
+
+ private Point mCenterCoordinate;
+
+ private boolean mAnimated;
+ private double mHeading;
+ private double mPitch;
+ private double mZoomLevel;
+
+ private boolean mFollowUserLocation;
+ private String mFollowUserMode;
+
+ private Context mContext;
+
+
+ private LocationManager.OnUserLocationChange mLocationChangeListener = new LocationManager.OnUserLocationChange() {
+ @Override
+ public void onLocationChange(Location nextLocation) {
+ if (getMapboxMap() == null || mLocationComponent == null || !mShowUserLocation) {
+ return;
+ }
+
+ float distToNextLocation = mUserLocation.getDistance(nextLocation);
+ mLocationComponent.forceLocationUpdate(nextLocation); // FMTODO - use builtin location tracking.
+ mUserLocation.setCurrentLocation(nextLocation);
+
+ if (mUserTrackingState == UserTrackingState.POSSIBLE || distToNextLocation > 0.0f) {
+ updateUserLocation(true);
+ }
+ sendUserLocationUpdateEvent(nextLocation);
+ }
+ };
+
+ private MapboxMap.CancelableCallback mCameraCallback = new MapboxMap.CancelableCallback() {
+ @Override
+ public void onCancel() {
+ if (!hasSentFirstRegion) {
+ mMapView.sendRegionChangeEvent(false);
+ hasSentFirstRegion = true;
+ }
+ }
+
+ @Override
+ public void onFinish() {
+ if (!hasSentFirstRegion) {
+ mMapView.sendRegionChangeEvent(false);
+ hasSentFirstRegion = true;
+ }
+ }
+ };
+
+ public RCTMGLCamera(Context context, RCTMGLCameraManager manager) {
+ super(context);
+ mContext = context;
+ mManager = manager;
+ mCameraUpdateQueue = new CameraUpdateQueue();
+
+ mUserLocation = new UserLocation();
+ mLocationManager = LocationManager.getInstance(context);
+ }
+
+ @Override
+ public void addToMap(RCTMGLMapView mapView) {
+ mMapView = mapView;
+
+ if (mCameraStop != null) {
+ updateCamera();
+ }
+
+ if (mShowUserLocation) {
+ enableLocation();
+ }
+ }
+
+ @Override
+ public void removeFromMap(RCTMGLMapView mapView) {
+
+ }
+
+ public void setStop(CameraStop stop) {
+ mCameraStop = stop;
+ mCameraStop.setCallback(mCameraCallback);
+
+ if (mMapView != null) {
+ updateCamera();
+ }
+ }
+
+ private void updateCamera() {
+ mCameraUpdateQueue.offer(mCameraStop);
+ mCameraUpdateQueue.execute(mMapView.getMapboxMap());
+ }
+
+ private void updateUserTrackingMode(int userTrackingMode) {
+ mUserLocation.setTrackingMode(userTrackingMode);
+ IEvent event = new MapUserTrackingModeEvent(this, userTrackingMode);
+ mManager.handleEvent(event);
+ }
+
+ private void updateUserLocation(boolean isAnimated) {
+ if (!mShowUserLocation || mUserLocation.getTrackingMode() == UserTrackingMode.NONE) {
+ return;
+ }
+
+ if (mUserTrackingState == UserTrackingState.POSSIBLE) {
+ updateUserLocationSignificantly(isAnimated);
+ } else if (mUserTrackingState == UserTrackingState.CHANGED) {
+ updateUserLocationIncrementally(isAnimated);
+ }
+ }
+
+ private CameraPosition getUserLocationUpdateCameraPosition(double zoomLevel) {
+ LatLng center = mUserLocation.getCoordinate();
+
+ if (mUserLocationVerticalAlignment != UserLocationVerticalAlignment.CENTER) {
+ VisibleRegion region = mMapView.getVisibleRegion(center, zoomLevel);
+
+ switch (mUserLocationVerticalAlignment) {
+ case UserLocationVerticalAlignment.TOP:
+ center = new LatLng(region.nearRight.getLatitude(), center.getLongitude());
+ break;
+ case UserLocationVerticalAlignment.BOTTOM:
+ center = new LatLng(region.farLeft.getLatitude(), center.getLongitude());
+ break;
+ }
+ }
+
+ return new CameraPosition.Builder()
+ .target(center)
+ .bearing(getDirectionForUserLocationUpdate())
+ .tilt(mPitch)
+ .zoom(zoomLevel)
+ .build();
+ }
+
+ private double getDirectionForUserLocationUpdate() {
+ // NOTE: The direction of this is used for map rotation only, not location layer rotation
+ CameraPosition currentCamera = mMapView.getCameraPosition();
+ double direction = currentCamera.bearing;
+
+ int userTrackingMode = mUserLocation.getTrackingMode();
+ if (userTrackingMode == UserTrackingMode.FollowWithHeading || userTrackingMode == UserTrackingMode.FollowWithCourse) {
+ direction = mUserLocation.getBearing();
+ } else if (mHeading != 0.0) {
+ direction = mHeading;
+ }
+
+ return direction;
+ }
+
+ private void sendUserLocationUpdateEvent(Location location) {
+ if(location == null){
+ return;
+ }
+ IEvent event = new MapChangeEvent(this, makeLocationChangePayload(location), EventTypes.USER_LOCATION_UPDATED);
+ mManager.handleEvent(event);
+ }
+
+ private boolean hasSetCenterCoordinate() {
+ CameraPosition cameraPosition = mMapView.getCameraPosition();
+ LatLng center = cameraPosition.target;
+ return center.getLatitude() != 0.0 && center.getLongitude() != 0.0;
+ }
+
+
+ private void updateUserLocationSignificantly(boolean isAnimated) {
+ mUserTrackingState = UserTrackingState.BEGAN;
+
+ CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(getUserLocationUpdateCameraPosition(mZoomLevel));
+ MapboxMap.CancelableCallback cameraCallback = new MapboxMap.CancelableCallback() {
+ @Override
+ public void onCancel() {
+ mUserTrackingState = UserTrackingState.CHANGED;
+ }
+
+ @Override
+ public void onFinish() {
+ mUserTrackingState = UserTrackingState.CHANGED;
+ }
+ };
+
+ if (isAnimated && hasSetCenterCoordinate()) {
+ mMapView.animateCamera(cameraUpdate, cameraCallback);
+ } else {
+ mMapView.moveCamera(cameraUpdate, cameraCallback);
+ }
+ }
+
+ private void updateUserLocationIncrementally(boolean isAnimated) {
+ mUserTrackingState = UserTrackingState.BEGAN;
+
+ CameraPosition cameraPosition = mMapView.getCameraPosition();
+ CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(getUserLocationUpdateCameraPosition(cameraPosition.zoom));
+
+ MapboxMap.CancelableCallback callback = new MapboxMap.CancelableCallback() {
+ @Override
+ public void onCancel() {
+ mUserTrackingState = UserTrackingState.CHANGED;
+ }
+
+ @Override
+ public void onFinish() {
+ mUserTrackingState = UserTrackingState.CHANGED;
+ }
+ };
+
+ if (isAnimated) {
+ mMapView.easeCamera(cameraUpdate, USER_LOCATION_CAMERA_MOVE_DURATION, callback);
+ } else {
+ mMapView.moveCamera(cameraUpdate, callback);
+ }
+ }
+
+ public void setReactUserTrackingMode(int userTrackingMode) {
+ int oldTrackingMode = mUserTrackingMode;
+ mUserTrackingMode = userTrackingMode;
+ updateUserTrackingMode(userTrackingMode);
+
+ switch (mUserTrackingMode) {
+ case UserTrackingMode.NONE:
+ mUserTrackingState = UserTrackingState.POSSIBLE;
+ break;
+ case UserTrackingMode.FOLLOW:
+ case UserTrackingMode.FollowWithCourse:
+ case UserTrackingMode.FollowWithHeading:
+ if (oldTrackingMode == UserTrackingMode.NONE) {
+ mUserTrackingState = UserTrackingState.POSSIBLE;
+ }
+ mShowUserLocation = true;
+ break;
+
+ }
+
+ if (mMapView != null) {
+ updateUserLocation(false);
+ updateLocationLayer(mMapView.getMapboxMap().getStyle());
+ }
+ }
+
+ private void enableLocation() {
+ if (!PermissionsManager.areLocationPermissionsGranted(mContext)) {
+ return;
+ }
+
+ if (!mLocationManager.isActive()) {
+ mLocationManager.enable();
+ }
+
+ mMapView.getMapboxMap().getStyle(new Style.OnStyleLoaded() {
+ @Override
+ public void onStyleLoaded(@NonNull Style style) {
+ enableLocationComponent(style);
+ }
+ });
+ }
+
+ private void enableLocationComponent(@NonNull Style style) {
+ updateLocationLayer(style);
+
+ Location lastKnownLocation = mLocationManager.getLastKnownLocation();
+ mLocationManager.addLocationListener(mLocationChangeListener);
+
+ if (lastKnownLocation != null) {
+ mLocationChangeListener.onLocationChange(lastKnownLocation);
+
+ postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ mMapView.sendRegionDidChangeEvent();
+ }
+ }, 200);
+ }
+
+ }
+
+ private void updateLocationLayer(@NonNull Style style) {
+ if (mLocationComponent == null) {
+ mLocationComponent = getMapboxMap().getLocationComponent();
+ }
+
+ LocationComponentOptions locationComponentOptions = LocationComponentOptions.builder(mContext)
+ .build();
+
+ LocationComponentActivationOptions locationComponentActivationOptions = LocationComponentActivationOptions
+ .builder(mContext, style)
+ .locationComponentOptions(locationComponentOptions)
+ .build();
+ mLocationComponent.activateLocationComponent(locationComponentActivationOptions);
+ mLocationComponent.setLocationEngine(mLocationManager.getEngine());
+
+ int userLayerMode = UserTrackingMode.getMapLayerMode(mUserLocation.getTrackingMode(), mShowUserLocation);
+ mLocationComponent.setLocationComponentEnabled(userLayerMode != -1);
+
+ if (userLayerMode != -1) {
+ mLocationComponent.setRenderMode(userLayerMode);
+ }
+ }
+
+ public void setZoomLevel(double zoomLevel) {
+ mZoomLevel = zoomLevel;
+ updateCameraPositionIfNeeded(false);
+ }
+
+ private CameraPosition buildCamera(CameraPosition previousPosition, boolean shouldUpdateTarget) {
+ CameraPosition.Builder builder = new CameraPosition.Builder(previousPosition)
+ .bearing(mHeading)
+ .tilt(mPitch)
+ .zoom(mZoomLevel);
+
+ if (shouldUpdateTarget) {
+ builder.target(GeoJSONUtils.toLatLng(mCenterCoordinate));
+ }
+
+ return builder.build();
+ }
+
+ private void updateCameraPositionIfNeeded(boolean shouldUpdateTarget) {
+ if (mMapView != null) {
+ CameraPosition prevPosition = mMapView.getCameraPosition();
+ CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(buildCamera(prevPosition, shouldUpdateTarget));
+
+ if (mAnimated) {
+ mMapView.easeCamera(cameraUpdate);
+ } else {
+ mMapView.moveCamera(cameraUpdate);
+ }
+ }
+ }
+
+ public void setUserTrackingMode(int userTrackingMode) {
+ int oldTrackingMode = mUserTrackingMode;
+ mUserTrackingMode = userTrackingMode;
+ updateUserTrackingMode(userTrackingMode);
+
+ switch (mUserTrackingMode) {
+ case UserTrackingMode.NONE:
+ mUserTrackingState = UserTrackingState.POSSIBLE;
+ break;
+ case UserTrackingMode.FOLLOW:
+ case UserTrackingMode.FollowWithCourse:
+ case UserTrackingMode.FollowWithHeading:
+ if (oldTrackingMode == UserTrackingMode.NONE) {
+ mUserTrackingState = UserTrackingState.POSSIBLE;
+ }
+ mShowUserLocation = true;
+ break;
+
+ }
+
+ if (getMapboxMap() != null) {
+ updateUserLocation(false);
+ updateLocationLayer(getMapboxMap().getStyle());
+ }
+ }
+
+
+ public void setFollowUserLocation(boolean value) {
+ mFollowUserLocation = value;
+ if (value) {
+ setUserTrackingMode(UserTrackingMode.FOLLOW);
+ } else {
+ setUserTrackingMode(UserTrackingMode.NONE);
+ }
+ }
+
+ public void setFollowUserMode(String mode) {
+ mFollowUserMode = mode;
+
+ }
+
+ MapboxMap getMapboxMap() {
+ if (mMapView == null) {
+ return null;
+ }
+ return mMapView.getMapboxMap();
+ }
+
+ /**
+ * Create a payload of the location data per the web api geolocation spec
+ * https://dev.w3.org/geo/api/spec-source.html#position
+ * @return
+ */
+ private WritableMap makeLocationChangePayload(Location location) {
+ WritableMap positionProperties = new WritableNativeMap();
+ WritableMap coords = new WritableNativeMap();
+
+ coords.putDouble("longitude", location.getLongitude());
+ coords.putDouble("latitude", location.getLatitude());
+ coords.putDouble("altitude", location.getAltitude());
+ coords.putDouble("accuracy", location.getAccuracy());
+ coords.putDouble("heading", location.getBearing());
+ coords.putDouble("speed", location.getSpeed());
+
+ positionProperties.putMap("coords", coords);
+ positionProperties.putDouble("timestamp", location.getTime());
+ return positionProperties;
+ }
+}
diff --git a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/RCTMGLCameraManager.java b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/RCTMGLCameraManager.java
new file mode 100644
index 0000000000..6de75d0e29
--- /dev/null
+++ b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/camera/RCTMGLCameraManager.java
@@ -0,0 +1,65 @@
+package com.mapbox.rctmgl.components.camera;
+
+import com.facebook.common.logging.FLog;
+import com.facebook.react.bridge.ReactApplicationContext;
+import com.facebook.react.bridge.ReadableMap;
+import com.facebook.react.uimanager.ThemedReactContext;
+import com.facebook.react.uimanager.annotations.ReactProp;
+import com.mapbox.rctmgl.components.AbstractEventEmitter;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class RCTMGLCameraManager extends AbstractEventEmitter {
+ public static final String REACT_CLASS = RCTMGLCamera.class.getSimpleName();
+
+ private ReactApplicationContext mContext;
+
+ public RCTMGLCameraManager(ReactApplicationContext context) {
+ super(context);
+ mContext = context;
+ }
+
+ @Override
+ public Map customEvents() {
+ return new HashMap<>();
+ }
+
+ @Override
+ public String getName() {
+ return REACT_CLASS;
+ }
+
+ @Override
+ protected RCTMGLCamera createViewInstance(ThemedReactContext reactContext) {
+ return new RCTMGLCamera(reactContext, this);
+ }
+
+ @ReactProp(name="stop")
+ public void setStop(RCTMGLCamera camera, ReadableMap map) {
+ if (map != null) {
+ CameraStop stop = CameraStop.fromReadableMap(mContext, map, null);
+ camera.setStop(stop);
+ }
+ }
+
+ @ReactProp(name="userTrackingMode")
+ public void setUserTrackingMode(RCTMGLCamera camera, int userTrackingMode) {
+ camera.setUserTrackingMode(userTrackingMode);
+ }
+
+ @ReactProp(name="followZoomLevel")
+ public void setZoomLevel(RCTMGLCamera camera, double zoomLevel) {
+ camera.setZoomLevel(zoomLevel);
+ }
+
+ @ReactProp(name="followUserLocation")
+ public void setFollowUserLocation(RCTMGLCamera camera, boolean value) {
+ camera.setFollowUserLocation(value);
+ }
+
+ @ReactProp(name="followUserMode")
+ public void setFollowUserMode(RCTMGLCamera camera, String value) {
+ camera.setFollowUserMode(value);
+ }
+}
diff --git a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.java b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.java
index 046cf62680..b5c03dd84b 100644
--- a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.java
+++ b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.java
@@ -21,9 +21,14 @@
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeArray;
import com.facebook.react.bridge.WritableNativeMap;
+import com.mapbox.android.core.permissions.PermissionsManager;
+import com.mapbox.geojson.Feature;
+import com.mapbox.geojson.FeatureCollection;
+import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.annotations.Marker;
-import com.mapbox.mapboxsdk.annotations.MarkerView;
-import com.mapbox.mapboxsdk.annotations.MarkerViewManager;
+import com.mapbox.mapboxsdk.maps.Style;
+import com.mapbox.mapboxsdk.plugins.markerview.MarkerView;
+import com.mapbox.mapboxsdk.plugins.markerview.MarkerViewManager;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdate;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
@@ -36,7 +41,8 @@
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.maps.UiSettings;
import com.mapbox.mapboxsdk.plugins.localization.LocalizationPlugin;
-import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin;
+// import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin;
+import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.Property;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
@@ -47,6 +53,7 @@
import com.mapbox.rctmgl.components.annotation.RCTMGLPointAnnotationAdapter;
import com.mapbox.rctmgl.components.camera.CameraStop;
import com.mapbox.rctmgl.components.camera.CameraUpdateQueue;
+import com.mapbox.rctmgl.components.camera.RCTMGLCamera;
import com.mapbox.rctmgl.components.mapview.helpers.CameraChangeTracker;
import com.mapbox.rctmgl.components.styles.light.RCTMGLLight;
import com.mapbox.rctmgl.components.styles.sources.RCTSource;
@@ -61,18 +68,11 @@
import com.mapbox.rctmgl.location.UserLocation;
import com.mapbox.rctmgl.location.UserLocationLayerConstants;
import com.mapbox.rctmgl.location.UserLocationVerticalAlignment;
-import com.mapbox.rctmgl.location.UserTrackingMode;
import com.mapbox.rctmgl.location.UserTrackingState;
import com.mapbox.rctmgl.utils.BitmapUtils;
-import com.mapbox.rctmgl.utils.FilterParser;
import com.mapbox.rctmgl.utils.GeoJSONUtils;
import com.mapbox.rctmgl.utils.GeoViewport;
import com.mapbox.rctmgl.utils.SimpleEventCallback;
-import com.mapbox.services.android.telemetry.permissions.PermissionsManager;
-import com.mapbox.services.commons.geojson.Feature;
-import com.mapbox.services.commons.geojson.FeatureCollection;
-import com.mapbox.services.commons.geojson.Point;
-import com.mapbox.services.commons.models.Position;
import java.util.ArrayList;
import java.util.HashMap;
@@ -83,6 +83,7 @@
import javax.annotation.Nullable;
+
/**
* Created by nickitaliano on 8/18/17.
*/
@@ -90,11 +91,14 @@
@SuppressWarnings({"MissingPermission"})
public class RCTMGLMapView extends MapView implements
OnMapReadyCallback, MapboxMap.OnMapClickListener, MapboxMap.OnMapLongClickListener,
- MapView.OnMapChangedListener, MapboxMap.OnMarkerViewClickListener {
+ /* MapView.OnMapChangedListener*/
+ MapView.OnCameraDidChangeListener, MapView.OnDidFailLoadingMapListener,
+ MapView.OnDidFinishLoadingMapListener, MapView.OnWillStartRenderingFrameListener,
+ MapView.OnDidFinishRenderingFrameListener, MapView.OnWillStartRenderingMapListener,
+ MapView.OnDidFinishRenderingMapListener, MapView.OnDidFinishLoadingStyleListener,
+ MapboxMap.OnMarkerClickListener {
public static final String LOG_TAG = RCTMGLMapView.class.getSimpleName();
- public static final int USER_LOCATION_CAMERA_MOVE_DURATION = 1000;
-
private RCTMGLMapViewManager mManager;
private Context mContext;
private Handler mHandler;
@@ -102,25 +106,19 @@ public class RCTMGLMapView extends MapView implements
private boolean mPaused;
private boolean mDestroyed;
+ private RCTMGLCamera mCamera;
private List mFeatures;
private List mQueuedFeatures;
private Map mPointAnnotations;
private Map mSources;
- private CameraUpdateQueue mCameraUpdateQueue;
private CameraChangeTracker mCameraChangeTracker = new CameraChangeTracker();
private Map mPreRenderMethodMap = new HashMap<>();
private MapboxMap mMap;
- private LocationManager mLocationManger;
- private UserLocation mUserLocation;
-
- private LocationLayerPlugin mLocationLayer;
- private LocalizationPlugin mLocalizationPlugin;
private String mStyleURL;
- private boolean mAnimated;
private boolean mLocalizeLabels;
private Boolean mScrollEnabled;
private Boolean mPitchEnabled;
@@ -129,44 +127,15 @@ public class RCTMGLMapView extends MapView implements
private Boolean mLogoEnabled;
private Boolean mCompassEnabled;
private Boolean mZoomEnabled;
- private boolean mShowUserLocation;
-
- private long mActiveMarkerID = -1;
- private int mUserTrackingMode;
- private int mUserTrackingState = UserTrackingState.POSSIBLE;
- private int mUserLocationVerticalAlignment = UserLocationVerticalAlignment.CENTER;
- private double mHeading;
- private double mPitch;
- private double mZoomLevel;
+ private MarkerViewManager markerViewManager;
- private Double mMinZoomLevel;
- private Double mMaxZoomLevel;
+ private long mActiveMarkerID = -1;
private ReadableArray mInsets;
- private Point mCenterCoordinate;
- private LatLngBounds mVisibleCoordinateBounds;
private HashSet mHandledMapChangedEvents = null;
- private LocationManager.OnUserLocationChange mLocationChangeListener = new LocationManager.OnUserLocationChange() {
- @Override
- public void onLocationChange(Location nextLocation) {
- if (mMap == null || mLocationLayer == null || !mShowUserLocation) {
- return;
- }
-
- float distToNextLocation = mUserLocation.getDistance(nextLocation);
- mLocationLayer.onLocationChanged(nextLocation);
- mUserLocation.setCurrentLocation(nextLocation);
-
- if (mUserTrackingState == UserTrackingState.POSSIBLE || distToNextLocation > 0.0f) {
- updateUserLocation(true);
- }
- sendUserLocationUpdateEvent(nextLocation);
- }
- };
-
public RCTMGLMapView(Context context, RCTMGLMapViewManager manager, MapboxMapOptions options) {
super(context, options);
@@ -178,11 +147,6 @@ public RCTMGLMapView(Context context, RCTMGLMapViewManager manager, MapboxMapOpt
getMapAsync(this);
mManager = manager;
- mCameraUpdateQueue = new CameraUpdateQueue();
-
- mUserLocation = new UserLocation();
- mLocationManger = new LocationManager(context);
- mLocationManger.setOnLocationChangeListener(mLocationChangeListener);
mSources = new HashMap<>();
mPointAnnotations = new HashMap<>();
@@ -193,7 +157,16 @@ public RCTMGLMapView(Context context, RCTMGLMapViewManager manager, MapboxMapOpt
setLifecycleListeners();
- addOnMapChangedListener(this);
+// addOnMapChangedListener(this);
+ addOnCameraDidChangeListener(this);
+ addOnDidFailLoadingMapListener(this);
+ addOnDidFinishLoadingMapListener(this);
+
+ addOnWillStartRenderingFrameListener(this);
+ addOnDidFinishRenderingFrameListener(this);
+ addOnWillStartRenderingMapListener(this);
+ addOnDidFinishRenderingMapListener(this);
+ addOnDidFinishLoadingStyleListener(this);
}
@Override
@@ -214,20 +187,6 @@ public void onDestroy() {
mDestroyed = true;
}
- @Override
- public void onWindowFocusChanged(boolean hasWindowFocus) {
- super.onWindowFocusChanged(hasWindowFocus);
- if (mLocationLayer == null) {
- return;
- }
- if (hasWindowFocus) {
- mLocationLayer.onStart();
- } else {
- mLocationLayer.onStop();
- }
-
- }
-
public void enqueuePreRenderMapMethod(Integer methodID, @Nullable ReadableArray args) {
mPreRenderMethodMap.put(methodID, args);
}
@@ -245,6 +204,10 @@ public void addFeature(View childView, int childPosition) {
RCTMGLPointAnnotation annotation = (RCTMGLPointAnnotation) childView;
mPointAnnotations.put(annotation.getID(), annotation);
feature = (AbstractMapFeature) childView;
+ } else if (childView instanceof RCTMGLCamera) {
+ RCTMGLCamera camera = (RCTMGLCamera) childView;
+ mCamera = camera;
+ feature = (AbstractMapFeature) childView;
} else {
ViewGroup children = (ViewGroup) childView;
@@ -303,12 +266,6 @@ public synchronized void dispose() {
ReactContext reactContext = (ReactContext) mContext;
reactContext.removeLifecycleEventListener(mLifeCycleListener);
- if(mLocationLayer != null){
- mLocationLayer.onStop();
- }
-
- mLocationManger.dispose();
-
if (!mPaused) {
onPause();
}
@@ -317,6 +274,42 @@ public synchronized void dispose() {
onDestroy();
}
+ public VisibleRegion getVisibleRegion(LatLng center, double zoomLevel) {
+ DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
+ int[] contentPadding = mMap.getPadding();
+
+ // we want to get the width, and height scaled based on pixel density, that also includes content padding
+ // (width * percentOfWidthWeWant - (leftPadding + rightPadding)) / dpi
+ int mapWidth = (int)((mMap.getWidth() * 0.75 - (contentPadding[0] + contentPadding[2])) / metrics.scaledDensity);
+ int mapHeight = (int)((mMap.getHeight() * 0.75 - (contentPadding[1] + contentPadding[3])) / metrics.scaledDensity);
+ VisibleRegion region = GeoViewport.getRegion(center, (int) zoomLevel, mapWidth, mapHeight);
+ return region;
+ }
+
+ public CameraPosition getCameraPosition() {
+ return mMap.getCameraPosition();
+ }
+
+ public void animateCamera(CameraUpdate cameraUpdate, MapboxMap.CancelableCallback callback) {
+ mMap.animateCamera(cameraUpdate, callback);
+ }
+
+ public void moveCamera(CameraUpdate cameraUpdate, MapboxMap.CancelableCallback callback) {
+ mMap.moveCamera(cameraUpdate, callback);
+ }
+
+ public void moveCamera(CameraUpdate cameraUpdate) {
+ mMap.moveCamera(cameraUpdate);
+ }
+
+ public void easeCamera(CameraUpdate cameraUpdate, int duration, MapboxMap.CancelableCallback callback) {
+ mMap.easeCamera(cameraUpdate, duration, callback);
+ }
+
+ public void easeCamera(CameraUpdate cameraUpdate) {
+ mMap.easeCamera(cameraUpdate);
+ }
+
public RCTMGLPointAnnotation getPointAnnotationByID(String annotationID) {
if (annotationID == null) {
return null;
@@ -355,45 +348,24 @@ public MapboxMap getMapboxMap() {
public void onMapReady(final MapboxMap mapboxMap) {
mMap = mapboxMap;
+ mMap.setStyle(new Style.Builder().fromUrl(mStyleURL));
+
reflow(); // the internal widgets(compass, attribution, etc) need this to position themselves correctly
- final MarkerViewManager markerViewManager = mMap.getMarkerViewManager();
- markerViewManager.addMarkerViewAdapter(new RCTMGLPointAnnotationAdapter(this, mContext));
- markerViewManager.setOnMarkerViewClickListener(this);
+ mMap.setOnMarkerClickListener(this);
+
+ markerViewManager = new MarkerViewManager(this, mMap); /* mMap.getMarkerViewManager(); */
+ // FMTODO markerViewManager.addMarker(new RCTMGLPointAnnotationAdapter(this, mContext));
+ // FMTODO markerViewManager.addMarkerViewAdapter(new RCTMGLPointAnnotationAdapter(this, mContext));
+ // FMTODO markerViewManager.setOnMarkerViewClickListener(this);
mMap.setInfoWindowAdapter(new RCTMGLCalloutAdapter(this));
- mMap.setOnMapClickListener(this);
- mMap.setOnMapLongClickListener(this);
+ mMap.addOnMapClickListener(this);
+ mMap.addOnMapLongClickListener(this);
// in case props were set before the map was ready lets set them
updateInsets();
updateUISettings();
- setMinMaxZoomLevels();
-
- if (mShowUserLocation) {
- enableLocation();
- }
-
- // extract target centerCoordinate / zoomLevel from mVisibleCoordinateBounds
- updateCenterCoordinateIfNeeded();
-
- if (mCenterCoordinate != null && mUserTrackingMode == UserTrackingMode.NONE) {
- mMap.moveCamera(CameraUpdateFactory.newCameraPosition(buildCamera()), new MapboxMap.CancelableCallback() {
- @Override
- public void onCancel() {
- sendRegionDidChangeEvent();
- }
-
- @Override
- public void onFinish() {
- sendRegionDidChangeEvent();
- }
- });
- }
-
- if (!mCameraUpdateQueue.isEmpty()) {
- mCameraUpdateQueue.execute(mMap);
- }
if (mQueuedFeatures.size() > 0) {
for (int i = 0; i < mQueuedFeatures.size(); i++) {
@@ -404,16 +376,18 @@ public void onFinish() {
mQueuedFeatures = null;
}
+ /* FMTODO
if (mPointAnnotations.size() > 0) {
markerViewManager.invalidateViewMarkersInVisibleRegion();
- }
+ } */
mMap.addOnCameraIdleListener(new MapboxMap.OnCameraIdleListener() {
@Override
public void onCameraIdle() {
+ /* FMTODO
if (mPointAnnotations.size() > 0) {
markerViewManager.invalidateViewMarkersInVisibleRegion();
- }
+ } */
// if we have onCameraIdle during mCameraChangeTracker.isAnimating()
// it's a 'fling animation' after user gesture
@@ -459,49 +433,7 @@ public void onCameraMoveStarted(int reason) {
}
});
- mMap.setOnScrollListener(new MapboxMap.OnScrollListener() {
- @Override
- public void onScroll() {
- if (mUserLocation.getTrackingMode() != UserTrackingMode.NONE) {
- updateUserTrackingMode(UserTrackingMode.NONE);
- }
- }
- });
-
- mMap.setOnFlingListener(new MapboxMap.OnFlingListener() {
- @Override
- public void onFling() {
- if (mUserLocation.getTrackingMode() != UserTrackingMode.NONE) {
- updateUserTrackingMode(UserTrackingMode.NONE);
- }
- }
- });
-
- mMap.addOnCameraMoveListener(new MapboxMap.OnCameraMoveListener() {
- double lastMapRotation = getMapRotation();
-
- @Override
- public void onCameraMove() {
- handleMapChangedEvent(EventTypes.REGION_IS_CHANGING);
-
- int userTrackingMode = mUserLocation.getTrackingMode();
- boolean isFollowWithCourseOrHeading = userTrackingMode == UserTrackingMode.FollowWithCourse || userTrackingMode == UserTrackingMode.FollowWithHeading;
-
- if (!isFollowWithCourseOrHeading) {
- lastMapRotation = getRotation();
- return;
- }
-
- double currentMapRotation = getMapRotation();
- if (lastMapRotation != currentMapRotation && mCameraChangeTracker.isUserInteraction()) {
- updateUserTrackingMode(UserTrackingMode.FOLLOW);
- }
-
- lastMapRotation = currentMapRotation;
- }
- });
-
- mLocalizationPlugin = new LocalizationPlugin(this, mMap);
+ /*mLocalizationPlugin = new LocalizationPlugin(this, mMap);
if (mLocalizeLabels) {
try {
mLocalizationPlugin.matchMapLanguageWithDeviceDefault();
@@ -509,7 +441,7 @@ public void onCameraMove() {
final String localeString = Locale.getDefault().toString();
Log.w(LOG_TAG, String.format("Could not find matching locale for %s", localeString));
}
- }
+ }*/
}
public void reflow() {
@@ -543,7 +475,7 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
}
@Override
- public void onMapClick(@NonNull LatLng point) {
+ public boolean onMapClick(@NonNull LatLng point) {
boolean isEventCaptured = false;
if (mActiveMarkerID != -1) {
@@ -557,7 +489,7 @@ public void onMapClick(@NonNull LatLng point) {
}
if (isEventCaptured) {
- return;
+ return true;
}
PointF screenPoint = mMap.getProjection().toScreenLocation(point);
@@ -592,23 +524,25 @@ public void onMapClick(@NonNull LatLng point) {
RCTSource source = getTouchableSourceWithHighestZIndex(hitTouchableSources);
if (source != null && source.hasPressListener()) {
source.onPress(hits.get(source.getID()));
- return;
+ return true;
}
}
MapClickEvent event = new MapClickEvent(this, point, screenPoint);
mManager.handleEvent(event);
+ return false;
}
@Override
- public void onMapLongClick(@NonNull LatLng point) {
+ public boolean onMapLongClick(@NonNull LatLng point) {
PointF screenPoint = mMap.getProjection().toScreenLocation(point);
MapClickEvent event = new MapClickEvent(this, point, screenPoint, EventTypes.MAP_LONG_CLICK);
mManager.handleEvent(event);
+ return false;
}
@Override
- public boolean onMarkerClick(@NonNull Marker marker, @NonNull View view, @NonNull MapboxMap.MarkerViewAdapter adapter) {
+ public boolean onMarkerClick(@NonNull Marker marker) {
final long selectedMarkerID = marker.getId();
RCTMGLPointAnnotation activeAnnotation = null;
@@ -640,27 +574,27 @@ public void selectAnnotation(RCTMGLPointAnnotation annotation) {
final long id = annotation.getMapboxID();
if (id != mActiveMarkerID) {
- final MarkerView markerView = annotation.getMarker();
- mMap.selectMarker(markerView);
+ final Marker marker = annotation.getMarker();
+ mMap.selectMarker(marker);
annotation.onSelect(true);
mActiveMarkerID = id;
RCTMGLCallout calloutView = annotation.getCalloutView();
- if (!markerView.isInfoWindowShown() && calloutView != null) {
- markerView.showInfoWindow(mMap, this);
+ if (!marker.isInfoWindowShown() && calloutView != null) {
+ marker.showInfoWindow(mMap, this);
}
}
}
public boolean deselectAnnotation(RCTMGLPointAnnotation annotation) {
- MarkerView markerView = annotation.getMarker();
+ Marker marker = annotation.getMarker();
RCTMGLCallout calloutView = annotation.getCalloutView();
if (calloutView != null) {
- markerView.hideInfoWindow();
+ marker.hideInfoWindow();
}
- mMap.deselectMarker(markerView);
+ mMap.deselectMarker(marker);
mActiveMarkerID = -1;
annotation.onDeselect();
@@ -668,6 +602,61 @@ public boolean deselectAnnotation(RCTMGLPointAnnotation annotation) {
}
@Override
+ public void onCameraDidChange(boolean animated) {
+ mCameraChangeTracker.setIsAnimating(animated);
+ }
+
+ @Override
+ public void onDidFailLoadingMap(String errorMessage) {
+ handleMapChangedEvent(EventTypes.DID_FAIL_LOADING_MAP);
+ }
+
+ @Override
+ public void onDidFinishLoadingMap() {
+ handleMapChangedEvent(EventTypes.DID_FINISH_LOADING_MAP);
+ }
+
+ @Override
+ public void onWillStartRenderingFrame() {
+ handleMapChangedEvent(EventTypes.WILL_START_RENDERING_FRAME);
+ }
+
+ @Override
+ public void onDidFinishRenderingFrame(boolean fully) {
+ if (fully) {
+ handleMapChangedEvent(EventTypes.DID_FINISH_RENDERING_FRAME_FULLY);
+ } else {
+ handleMapChangedEvent(EventTypes.DID_FINISH_RENDERING_FRAME);
+ }
+ }
+
+ @Override
+ public void onWillStartRenderingMap() {
+ handleMapChangedEvent(EventTypes.WILL_START_RENDERING_MAP);
+ }
+
+ @Override
+ public void onDidFinishRenderingMap(boolean fully) {
+ if (fully) {
+ if (mPreRenderMethodMap.size() > 0) {
+ for (Integer methodID : mPreRenderMethodMap.keySet()) {
+ mManager.receiveCommand(this, methodID, mPreRenderMethodMap.get(methodID));
+ }
+ mPreRenderMethodMap.clear();
+ }
+ handleMapChangedEvent(EventTypes.DID_FINISH_RENDERING_MAP_FULLY);
+ } else {
+ handleMapChangedEvent(EventTypes.DID_FINISH_RENDERING_MAP);
+ }
+ }
+
+ @Override
+ public void onDidFinishLoadingStyle() {
+ handleMapChangedEvent(EventTypes.DID_FINISH_LOADING_STYLE);
+ }
+
+
+ /*
public void onMapChanged(int changed) {
String eventType = null;
@@ -677,36 +666,36 @@ public void onMapChanged(int changed) {
case REGION_DID_CHANGE:
break;
case REGION_WILL_CHANGE_ANIMATED:
- mCameraChangeTracker.setIsAnimating(true);
+ mCameraChangeTracker.setIsAnimating(true); //*
break;
case REGION_DID_CHANGE_ANIMATED:
- mCameraChangeTracker.setIsAnimating(false);
+ mCameraChangeTracker.setIsAnimating(false); //*
break;
case WILL_START_LOADING_MAP:
eventType = EventTypes.WILL_START_LOADING_MAP;
break;
case DID_FAIL_LOADING_MAP:
- eventType = EventTypes.DID_FAIL_LOADING_MAP;
+ eventType = EventTypes.DID_FAIL_LOADING_MAP; //*
break;
case DID_FINISH_LOADING_MAP:
- eventType = EventTypes.DID_FINISH_LOADING_MAP;
+ eventType = EventTypes.DID_FINISH_LOADING_MAP; //*
break;
case WILL_START_RENDERING_FRAME:
- eventType = EventTypes.WILL_START_RENDERING_FRAME;
+ eventType = EventTypes.WILL_START_RENDERING_FRAME; //*
break;
case DID_FINISH_RENDERING_FRAME:
- eventType = EventTypes.DID_FINISH_RENDERING_FRAME;
+ eventType = EventTypes.DID_FINISH_RENDERING_FRAME; //*
break;
case DID_FINISH_RENDERING_FRAME_FULLY_RENDERED:
- eventType = EventTypes.DID_FINISH_RENDERING_FRAME_FULLY;
+ eventType = EventTypes.DID_FINISH_RENDERING_FRAME_FULLY; //*
break;
case WILL_START_RENDERING_MAP:
- eventType = EventTypes.WILL_START_RENDERING_MAP;
+ eventType = EventTypes.WILL_START_RENDERING_MAP; // *
break;
case DID_FINISH_RENDERING_MAP:
- eventType = EventTypes.DID_FINISH_RENDERING_MAP;
+ eventType = EventTypes.DID_FINISH_RENDERING_MAP; // *
break;
- case DID_FINISH_RENDERING_MAP_FULLY_RENDERED:
+ case DID_FINISH_RENDERING_MAP_FULLY_RENDERED: // * FMTODO no equivalent
if (mPreRenderMethodMap.size() > 0) {
for (Integer methodID : mPreRenderMethodMap.keySet()) {
mManager.receiveCommand(this, methodID, mPreRenderMethodMap.get(methodID));
@@ -716,14 +705,14 @@ public void onMapChanged(int changed) {
eventType = EventTypes.DID_FINISH_RENDERING_MAP_FULLY;
break;
case DID_FINISH_LOADING_STYLE:
- eventType = EventTypes.DID_FINISH_LOADING_STYLE;
+ eventType = EventTypes.DID_FINISH_LOADING_STYLE; //*
break;
}
if (eventType != null) {
handleMapChangedEvent(eventType);
}
- }
+ } */
//endregion
@@ -735,20 +724,15 @@ public void setReactStyleURL(String styleURL) {
if (mMap != null) {
removeAllSourcesFromMap();
- mMap.setStyle(styleURL, new MapboxMap.OnStyleLoadedListener() {
+ mMap.setStyle(styleURL, new Style.OnStyleLoaded() {
@Override
- public void onStyleLoaded(String style) {
+ public void onStyleLoaded(@NonNull Style style) {
addAllSourcesToMap();
}
});
}
}
- public void setReactAnimated(boolean animated) {
- mAnimated = animated;
- updateCameraPositionIfNeeded(false);
- }
-
public void setReactContentInset(ReadableArray array) {
mInsets = array;
updateInsets();
@@ -793,151 +777,12 @@ public void setReactAttributionEnabled(boolean attributionEnabled) {
updateUISettings();
}
- public void setReactHeading(double heading) {
- mHeading = heading;
- updateCameraPositionIfNeeded(false);
- }
-
- public void setReactPitch(double pitch) {
- mPitch = pitch;
- updateCameraPositionIfNeeded(false);
- }
-
- public void setReactZoomLevel(double zoomLevel) {
- mZoomLevel = zoomLevel;
- updateCameraPositionIfNeeded(false);
- }
-
- public void setReactMinZoomLevel(double minZoomLevel) {
- mMinZoomLevel = minZoomLevel;
- setMinMaxZoomLevels();
- }
-
- public void setReactMaxZoomLevel(double maxZoomLevel) {
- mMaxZoomLevel = maxZoomLevel;
- setMinMaxZoomLevels();
- }
-
- public void setReactCenterCoordinate(Point centerCoordinate) {
- mCenterCoordinate = centerCoordinate;
- updateCameraPositionIfNeeded(true);
- }
-
- public void setReactVisibleCoordinateBounds(LatLngBounds visibleCoordinateBounds) {
- mVisibleCoordinateBounds = visibleCoordinateBounds;
- updateCenterCoordinateIfNeeded();
- updateCameraPositionIfNeeded(true);
- }
-
- public void setReactShowUserLocation(boolean showUserLocation) {
- mShowUserLocation = showUserLocation;
-
- if (mMap != null) {
- if (mLocationManger.isActive() && !mShowUserLocation) {
- mLocationManger.disable();
-
- if (mLocationLayer != null) {
- int trackingMode = mUserLocation.getTrackingMode();
-
- if (trackingMode != UserTrackingMode.NONE) {
- mUserLocation.setTrackingMode(UserTrackingMode.NONE);
- updateUserTrackingMode(UserTrackingMode.NONE);
- }
-
- updateLocationLayer();
- }
- } else {
- enableLocation();
- }
- }
- }
-
- public void setReactUserTrackingMode(int userTrackingMode) {
- int oldTrackingMode = mUserTrackingMode;
- mUserTrackingMode = userTrackingMode;
- updateUserTrackingMode(userTrackingMode);
-
- switch (mUserTrackingMode) {
- case UserTrackingMode.NONE:
- mUserTrackingState = UserTrackingState.POSSIBLE;
- break;
- case UserTrackingMode.FOLLOW:
- case UserTrackingMode.FollowWithCourse:
- case UserTrackingMode.FollowWithHeading:
- if (oldTrackingMode == UserTrackingMode.NONE) {
- mUserTrackingState = UserTrackingState.POSSIBLE;
- }
- mShowUserLocation = true;
- break;
-
- }
-
- if (mMap != null) {
- updateUserLocation(false);
- updateLocationLayer();
- }
- }
-
- public void setReactUserLocationVerticalAlignment(int userLocationVerticalAlignment) {
- mUserLocationVerticalAlignment = userLocationVerticalAlignment;
-
- if (mMap != null && mUserLocation.getTrackingMode() != UserTrackingMode.NONE) {
- updateUserLocation(false);
- }
- }
-
//endregion
//region Methods
-
- public void setCamera(String callbackID, ReadableMap args) {
- IEvent event = new AndroidCallbackEvent(this, callbackID, EventKeys.MAP_ANDROID_CALLBACK);
- final SimpleEventCallback callback = new SimpleEventCallback(mManager, event);
-
- // remove any current camera updates
- mCameraUpdateQueue.flush();
-
- if (args.hasKey("stops")) {
- ReadableArray stops = args.getArray("stops");
-
- for (int i = 0; i < stops.size(); i++) {
- CameraStop stop = CameraStop.fromReadableMap(mContext, stops.getMap(i), null);
- mCameraUpdateQueue.offer(stop);
- }
-
- mCameraUpdateQueue.setOnCompleteAllListener(new CameraUpdateQueue.OnCompleteAllListener() {
- @Override
- public void onCompleteAll() {
- callback.onFinish();
- mCameraChangeTracker.setReason(3);
- }
- });
- } else {
- CameraStop stop = CameraStop.fromReadableMap(mContext, args, new MapboxMap.CancelableCallback() {
- @Override
- public void onCancel() {
- callback.onCancel();
- mCameraChangeTracker.setReason(1);
- }
-
- @Override
- public void onFinish() {
- callback.onFinish();
- mCameraChangeTracker.setReason(3);
- }
- });
- mCameraUpdateQueue.offer(stop);
- }
-
- // if map is already ready start executing on the queue
- if (mMap != null) {
- mCameraUpdateQueue.execute(mMap);
- }
- }
-
- public void queryRenderedFeaturesAtPoint(String callbackID, PointF point, FilterParser.FilterList filter, List layerIDs) {
+ public void queryRenderedFeaturesAtPoint(String callbackID, PointF point, Expression filter, List layerIDs) {
AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, EventKeys.MAP_ANDROID_CALLBACK);
- List features = mMap.queryRenderedFeatures(point, FilterParser.parse(filter), layerIDs.toArray(new String[layerIDs.size()]));
+ List features = mMap.queryRenderedFeatures(point, filter, layerIDs.toArray(new String[layerIDs.size()]));
WritableMap payload = new WritableNativeMap();
payload.putString("data", FeatureCollection.fromFeatures(features).toJson());
@@ -957,9 +802,9 @@ public void getZoom(String callbackID) {
mManager.handleEvent(event);
}
- public void queryRenderedFeaturesInRect(String callbackID, RectF rect, FilterParser.FilterList filter, List layerIDs) {
+ public void queryRenderedFeaturesInRect(String callbackID, RectF rect, Expression filter, List layerIDs) {
AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, EventKeys.MAP_ANDROID_CALLBACK);
- List features = mMap.queryRenderedFeatures(rect, FilterParser.parse(filter), layerIDs.toArray(new String[layerIDs.size()]));
+ List features = mMap.queryRenderedFeatures(rect, filter, layerIDs.toArray(new String[layerIDs.size()]));
WritableMap payload = new WritableNativeMap();
payload.putString("data", FeatureCollection.fromFeatures(features).toJson());
@@ -1048,8 +893,6 @@ public void showAttribution() {
}
public void init() {
- setStyleUrl(mStyleURL);
-
// very important, this will make sure that mapbox-gl-native initializes the gl surface
// https://github.com/mapbox/react-native-mapbox-gl/issues/955
getViewTreeObserver().dispatchOnGlobalLayout();
@@ -1059,50 +902,6 @@ public boolean isDestroyed(){
return mDestroyed;
}
-
- private void updateCenterCoordinateIfNeeded() {
- if (mMap != null && mVisibleCoordinateBounds != null) {
- CameraUpdate boundsUpdate = CameraUpdateFactory.newLatLngBounds(mVisibleCoordinateBounds, 0);
- CameraPosition boundsPosition = boundsUpdate.getCameraPosition(mMap);
- if (boundsPosition != null) {
- mCenterCoordinate = Point.fromCoordinates(Position.fromLngLat(
- boundsPosition.target.getLongitude(), boundsPosition.target.getLatitude()
- ));
- mZoomLevel = boundsPosition.zoom;
- }
- }
- }
-
- private void updateCameraPositionIfNeeded(boolean shouldUpdateTarget) {
- if (mMap != null) {
- CameraPosition prevPosition = mMap.getCameraPosition();
- CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(buildCamera(prevPosition, shouldUpdateTarget));
-
- if (mAnimated) {
- mMap.easeCamera(cameraUpdate);
- } else {
- mMap.moveCamera(cameraUpdate);
- }
- }
- }
-
- private CameraPosition buildCamera() {
- return buildCamera(null, true);
- }
-
- private CameraPosition buildCamera(CameraPosition previousPosition, boolean shouldUpdateTarget) {
- CameraPosition.Builder builder = new CameraPosition.Builder(previousPosition)
- .bearing(mHeading)
- .tilt(mPitch)
- .zoom(mZoomLevel);
-
- if (shouldUpdateTarget) {
- builder.target(GeoJSONUtils.toLatLng(mCenterCoordinate));
- }
-
- return builder.build();
- }
-
private void updateUISettings() {
if (mMap == null) {
return;
@@ -1171,37 +970,17 @@ private void updateInsets() {
Float.valueOf(bottom * metrics.scaledDensity).intValue());
}
- private void setMinMaxZoomLevels() {
- if (mMap == null) {
- return;
- }
-
- if (mMinZoomLevel != null) {
- mMap.setMinZoomPreference(mMinZoomLevel);
- }
-
- if (mMaxZoomLevel != null) {
- mMap.setMaxZoomPreference(mMaxZoomLevel);
- }
- }
-
private void setLifecycleListeners() {
final ReactContext reactContext = (ReactContext) mContext;
mLifeCycleListener = new LifecycleEventListener() {
@Override
public void onHostResume() {
- if (mShowUserLocation && !mLocationManger.isActive()) {
- mLocationManger.enable();
- }
onResume();
}
@Override
public void onHostPause() {
- if (mLocationManger.isActive()) {
- mLocationManger.disable();
- }
onPause();
}
@@ -1214,47 +993,7 @@ public void onHostDestroy() {
reactContext.addLifecycleEventListener(mLifeCycleListener);
}
- private void enableLocation() {
- if (!PermissionsManager.areLocationPermissionsGranted(mContext)) {
- return;
- }
-
- if (!mLocationManger.isActive()) {
- mLocationManger.enable();
- }
-
- updateLocationLayer();
-
- Location lastKnownLocation = mLocationManger.getLastKnownLocation();
- if (lastKnownLocation != null) {
- mLocationChangeListener.onLocationChange(lastKnownLocation);
-
- postDelayed(new Runnable() {
- @Override
- public void run() {
- sendRegionDidChangeEvent();
- }
- }, 200);
- }
- }
-
- private void updateLocationLayer() {
- if (mLocationLayer == null) {
- mLocationLayer = new LocationLayerPlugin(this, mMap, mLocationManger.getEngine());
- }
-
- int userLayerMode = UserTrackingMode.getMapLayerMode(mUserLocation.getTrackingMode(), mShowUserLocation);
- if (userLayerMode != mLocationLayer.getLocationLayerMode()) {
- mLocationLayer.setLocationLayerEnabled(userLayerMode);
-
- Layer accLayer = mMap.getLayer(UserLocationLayerConstants.ACCURACY_LAYER_ID);
- if (accLayer != null) {
- accLayer.setProperties(PropertyFactory.visibility(Property.NONE));
- }
- }
- }
-
- private WritableMap makeRegionPayload() {
+ private WritableMap makeRegionPayload(Boolean isAnimated) {
CameraPosition position = mMap.getCameraPosition();
LatLng latLng = new LatLng(position.target.getLatitude(), position.target.getLongitude());
@@ -1262,7 +1001,7 @@ private WritableMap makeRegionPayload() {
properties.putDouble("zoomLevel", position.zoom);
properties.putDouble("heading", position.bearing);
properties.putDouble("pitch", position.tilt);
- properties.putBoolean("animated", mCameraChangeTracker.isAnimated());
+ properties.putBoolean("animated", (null == isAnimated) ? mCameraChangeTracker.isAnimated() : isAnimated.booleanValue());
properties.putBoolean("isUserInteraction", mCameraChangeTracker.isUserInteraction());
VisibleRegion visibleRegion = mMap.getProjection().getVisibleRegion();
@@ -1271,6 +1010,12 @@ private WritableMap makeRegionPayload() {
return GeoJSONUtils.toPointFeature(latLng, properties);
}
+ public void sendRegionChangeEvent(boolean isAnimated) {
+ IEvent event = new MapChangeEvent(this, makeRegionPayload(new Boolean(isAnimated)), EventTypes.REGION_DID_CHANGE);
+ mManager.handleEvent(event);
+ mCameraChangeTracker.setReason(CameraChangeTracker.EMPTY);
+ }
+
private void removeAllSourcesFromMap() {
if (mSources.size() == 0) {
return;
@@ -1324,7 +1069,7 @@ private RCTSource getTouchableSourceWithHighestZIndex(List sources) {
}
// getLayers returns from back(N - 1) to front(0)
- List mapboxLayers = mMap.getLayers();
+ List mapboxLayers = mMap.getStyle().getLayers();
for (int i = mapboxLayers.size() - 1; i >= 0; i--) {
Layer mapboxLayer = mapboxLayers.get(i);
@@ -1337,118 +1082,6 @@ private RCTSource getTouchableSourceWithHighestZIndex(List sources) {
return null;
}
- private void updateUserTrackingMode(int userTrackingMode) {
- mUserLocation.setTrackingMode(userTrackingMode);
- IEvent event = new MapUserTrackingModeEvent(this, userTrackingMode);
- mManager.handleEvent(event);
- }
-
- private void updateUserLocation(boolean isAnimated) {
- if (!mShowUserLocation || mUserLocation.getTrackingMode() == UserTrackingMode.NONE) {
- return;
- }
-
- if (mUserTrackingState == UserTrackingState.POSSIBLE) {
- updateUserLocationSignificantly(isAnimated);
- } else if (mUserTrackingState == UserTrackingState.CHANGED) {
- updateUserLocationIncrementally(isAnimated);
- }
- }
-
- private void updateUserLocationSignificantly(boolean isAnimated) {
- mUserTrackingState = UserTrackingState.BEGAN;
-
- CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(getUserLocationUpdateCameraPosition(mZoomLevel));
- MapboxMap.CancelableCallback cameraCallback = new MapboxMap.CancelableCallback() {
- @Override
- public void onCancel() {
- mUserTrackingState = UserTrackingState.CHANGED;
- }
-
- @Override
- public void onFinish() {
- mUserTrackingState = UserTrackingState.CHANGED;
- }
- };
-
- if (isAnimated && hasSetCenterCoordinate()) {
- mMap.animateCamera(cameraUpdate, cameraCallback);
- } else {
- mMap.moveCamera(cameraUpdate, cameraCallback);
- }
- }
-
- private void updateUserLocationIncrementally(boolean isAnimated) {
- mUserTrackingState = UserTrackingState.BEGAN;
-
- CameraPosition cameraPosition = mMap.getCameraPosition();
- CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(getUserLocationUpdateCameraPosition(cameraPosition.zoom));
-
- MapboxMap.CancelableCallback callback = new MapboxMap.CancelableCallback() {
- @Override
- public void onCancel() {
- mUserTrackingState = UserTrackingState.CHANGED;
- }
-
- @Override
- public void onFinish() {
- mUserTrackingState = UserTrackingState.CHANGED;
- }
- };
-
- if (isAnimated) {
- mMap.easeCamera(cameraUpdate, USER_LOCATION_CAMERA_MOVE_DURATION, callback);
- } else {
- mMap.moveCamera(cameraUpdate, callback);
- }
- }
-
- private CameraPosition getUserLocationUpdateCameraPosition(double zoomLevel) {
- LatLng center = mUserLocation.getCoordinate();
-
- if (mUserLocationVerticalAlignment != UserLocationVerticalAlignment.CENTER) {
- DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
- int[] contentPadding = mMap.getPadding();
-
- // we want to get the width, and height scaled based on pixel density, that also includes content padding
- // (width * percentOfWidthWeWant - (leftPadding + rightPadding)) / dpi
- int mapWidth = (int)((mMap.getWidth() * 0.75 - (contentPadding[0] + contentPadding[2])) / metrics.scaledDensity);
- int mapHeight = (int)((mMap.getHeight() * 0.75 - (contentPadding[1] + contentPadding[3])) / metrics.scaledDensity);
- VisibleRegion region = GeoViewport.getRegion(center, (int) zoomLevel, mapWidth, mapHeight);
-
- switch (mUserLocationVerticalAlignment) {
- case UserLocationVerticalAlignment.TOP:
- center = new LatLng(region.nearRight.getLatitude(), center.getLongitude());
- break;
- case UserLocationVerticalAlignment.BOTTOM:
- center = new LatLng(region.farLeft.getLatitude(), center.getLongitude());
- break;
- }
- }
-
- return new CameraPosition.Builder()
- .target(center)
- .bearing(getDirectionForUserLocationUpdate())
- .tilt(mPitch)
- .zoom(zoomLevel)
- .build();
- }
-
- private double getDirectionForUserLocationUpdate() {
- // NOTE: The direction of this is used for map rotation only, not location layer rotation
- CameraPosition currentCamera = mMap.getCameraPosition();
- double direction = currentCamera.bearing;
-
- int userTrackingMode = mUserLocation.getTrackingMode();
- if (userTrackingMode == UserTrackingMode.FollowWithHeading || userTrackingMode == UserTrackingMode.FollowWithCourse) {
- direction = mUserLocation.getBearing();
- } else if (mHeading != 0.0) {
- direction = mHeading;
- }
-
- return direction;
- }
-
private boolean hasSetCenterCoordinate() {
CameraPosition cameraPosition = mMap.getCameraPosition();
LatLng center = cameraPosition.target;
@@ -1460,7 +1093,7 @@ private double getMapRotation() {
return cameraPosition.bearing;
}
- private void sendRegionDidChangeEvent() {
+ public void sendRegionDidChangeEvent() {
handleMapChangedEvent(EventTypes.REGION_DID_CHANGE);
mCameraChangeTracker.setReason(-1);
}
@@ -1475,7 +1108,7 @@ private void handleMapChangedEvent(String eventType) {
case EventTypes.REGION_WILL_CHANGE:
case EventTypes.REGION_DID_CHANGE:
case EventTypes.REGION_IS_CHANGING:
- event = new MapChangeEvent(this, makeRegionPayload(), eventType);
+ event = new MapChangeEvent(this, makeRegionPayload(null), eventType);
break;
default:
event = new MapChangeEvent(this, eventType);
diff --git a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/mapview/RCTMGLMapViewManager.java b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/mapview/RCTMGLMapViewManager.java
index 8d435993e1..901c63606a 100644
--- a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/mapview/RCTMGLMapViewManager.java
+++ b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/mapview/RCTMGLMapViewManager.java
@@ -14,10 +14,10 @@
import com.mapbox.rctmgl.components.AbstractEventEmitter;
import com.mapbox.rctmgl.events.constants.EventKeys;
import com.mapbox.rctmgl.utils.ConvertUtils;
-import com.mapbox.rctmgl.utils.FilterParser;
+import com.mapbox.rctmgl.utils.ExpressionParser;
import com.mapbox.rctmgl.utils.GeoJSONUtils;
-import com.mapbox.services.commons.geojson.FeatureCollection;
-import com.mapbox.services.commons.geojson.Point;
+import com.mapbox.geojson.FeatureCollection;
+import com.mapbox.geojson.Point;
import java.util.ArrayList;
import java.util.HashMap;
@@ -117,11 +117,6 @@ public void setStyleURL(RCTMGLMapView mapView, String styleURL) {
mapView.setReactStyleURL(styleURL);
}
- @ReactProp(name="animated")
- public void setAnimated(RCTMGLMapView mapView, boolean isAnimated) {
- mapView.setReactAnimated(isAnimated);
- }
-
@ReactProp(name="localizeLabels")
public void setLocalizeLabels(RCTMGLMapView mapView, boolean localizeLabels) {
mapView.setLocalizeLabels(localizeLabels);
@@ -162,68 +157,11 @@ public void setCompassEnabled(RCTMGLMapView mapView, boolean compassEnabled) {
mapView.setReactCompassEnabled(compassEnabled);
}
- @ReactProp(name="heading")
- public void setHeading(RCTMGLMapView mapView, double heading) {
- mapView.setReactHeading(heading);
- }
-
- @ReactProp(name="pitch")
- public void setPitch(RCTMGLMapView mapView, double pitch) {
- mapView.setReactPitch(pitch);
- }
-
- @ReactProp(name="zoomLevel")
- public void setZoomLevel(RCTMGLMapView mapView, double zoomLevel) {
- mapView.setReactZoomLevel(zoomLevel);
- }
-
- @ReactProp(name="minZoomLevel")
- public void setMinZoomLevel(RCTMGLMapView mapView, double minZoomLevel) {
- mapView.setReactMinZoomLevel(minZoomLevel);
- }
-
- @ReactProp(name="maxZoomLevel")
- public void setMaxZoomLevel(RCTMGLMapView mapView, double maxZoomLevel) {
- mapView.setReactMaxZoomLevel(maxZoomLevel);
- }
-
@ReactProp(name="contentInset")
public void setContentInset(RCTMGLMapView mapView, ReadableArray array) {
mapView.setReactContentInset(array);
}
- @ReactProp(name="centerCoordinate")
- public void setCenterCoordinate(RCTMGLMapView mapView, String featureJSONStr) {
- Point centerCoordinate = GeoJSONUtils.toPointGeometry(featureJSONStr);
- if (centerCoordinate != null) {
- mapView.setReactCenterCoordinate(centerCoordinate);
- }
- }
-
- @ReactProp(name="visibleCoordinateBounds")
- public void setVisibleCoordinateBounds(RCTMGLMapView mapView, String featureJSONStr) {
- FeatureCollection collection = FeatureCollection.fromJson(featureJSONStr);
- LatLngBounds bounds = GeoJSONUtils.toLatLngBounds(collection);
- if (bounds != null) {
- mapView.setReactVisibleCoordinateBounds(bounds);
- }
- }
-
- @ReactProp(name="showUserLocation")
- public void setShowUserLocation(RCTMGLMapView mapView, boolean showUserLocation) {
- mapView.setReactShowUserLocation(showUserLocation);
- }
-
- @ReactProp(name="userTrackingMode")
- public void setUserTrackingMode(RCTMGLMapView mapView, int userTrackingMode) {
- mapView.setReactUserTrackingMode(userTrackingMode);
- }
-
- @ReactProp(name="userLocationVerticalAlignment")
- public void setUserLocationVerticalAlignment(RCTMGLMapView mapView, int userLocationVerticalAlignment) {
- mapView.setReactUserLocationVerticalAlignment(userLocationVerticalAlignment);
- }
-
//endregion
//region Custom Events
@@ -243,8 +181,6 @@ public Map customEvents() {
//endregion
//region React Methods
-
- public static final int METHOD_SET_CAMERA = 1;
public static final int METHOD_QUERY_FEATURES_POINT = 2;
public static final int METHOD_QUERY_FEATURES_RECT = 3;
public static final int METHOD_VISIBLE_BOUNDS = 4;
@@ -260,7 +196,6 @@ public Map customEvents() {
@Override
public Map getCommandsMap() {
return MapBuilder.builder()
- .put("setCamera", METHOD_SET_CAMERA)
.put("queryRenderedFeaturesAtPoint", METHOD_QUERY_FEATURES_POINT)
.put("queryRenderedFeaturesInRect", METHOD_QUERY_FEATURES_RECT)
.put("getVisibleBounds", METHOD_VISIBLE_BOUNDS)
@@ -284,21 +219,18 @@ public void receiveCommand(RCTMGLMapView mapView, int commandID, @Nullable Reada
}
switch (commandID) {
- case METHOD_SET_CAMERA:
- mapView.setCamera(args.getString(0), args.getMap(1));
- break;
case METHOD_QUERY_FEATURES_POINT:
mapView.queryRenderedFeaturesAtPoint(
args.getString(0),
ConvertUtils.toPointF(args.getArray(1)),
- FilterParser.getFilterList(args.getArray(2)),
+ ExpressionParser.from(args.getArray(2)),
ConvertUtils.toStringList(args.getArray(3)));
break;
case METHOD_QUERY_FEATURES_RECT:
mapView.queryRenderedFeaturesInRect(
args.getString(0),
ConvertUtils.toRectF(args.getArray(1)),
- FilterParser.getFilterList(args.getArray(2)),
+ ExpressionParser.from(args.getArray(2)),
ConvertUtils.toStringList(args.getArray(3)));
break;
case METHOD_VISIBLE_BOUNDS:
diff --git a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/RCTMGLStyle.java b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/RCTMGLStyle.java
index 45d8e33097..786f04b7cc 100644
--- a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/RCTMGLStyle.java
+++ b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/RCTMGLStyle.java
@@ -4,7 +4,6 @@
import android.net.Uri;
import android.support.annotation.NonNull;
-import com.facebook.common.util.UriUtil;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableMapKeySetIterator;
import com.mapbox.mapboxsdk.maps.MapboxMap;
@@ -65,27 +64,16 @@ public void addImage(RCTMGLStyleValue styleValue) {
}
public void addImage(RCTMGLStyleValue styleValue, DownloadMapImageTask.OnAllImagesLoaded callback) {
- String uriStr = styleValue.getString(RCTMGLStyleFactory.VALUE_KEY);
- boolean shouldAddImage = styleValue.getBoolean(RCTMGLStyleFactory.SHOULD_ADD_IMAGE_KEY);
-
- if (!shouldAddImage) {
+ if (!styleValue.shouldAddImage()) {
if (callback != null) {
callback.onAllImagesLoaded();
}
return;
}
+ String uriStr = styleValue.getImageURI();
Map.Entry[] images = new Map.Entry[]{ new AbstractMap.SimpleEntry(uriStr, uriStr) };
DownloadMapImageTask task = new DownloadMapImageTask(mContext, mMap, callback);
task.execute(images);
}
-
- private boolean shouldAddImage(String uriStr) {
- return uriStr != null && isValidURI(uriStr);
- }
-
- private boolean isValidURI(String str) {
- Uri uri = Uri.parse(str);
- return UriUtil.isLocalAssetUri(uri) || UriUtil.isNetworkUri(uri);
- }
}
diff --git a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/RCTMGLStyleFactory.java b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/RCTMGLStyleFactory.java
index 602b956970..f4610ef9ae 100644
--- a/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/RCTMGLStyleFactory.java
+++ b/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/RCTMGLStyleFactory.java
@@ -568,9 +568,6 @@ public static void setRasterLayerStyle(final RasterLayer layer, RCTMGLStyle styl
case "rasterFadeDuration":
RCTMGLStyleFactory.setRasterFadeDuration(layer, styleValue);
break;
- case "rasterFadeDurationTransition":
- RCTMGLStyleFactory.setRasterFadeDurationTransition(layer, styleValue);
- break;
}
}
}
@@ -651,44 +648,20 @@ public static void setLightLayerStyle(final Light layer, RCTMGLStyle style) {
}
public static void setVisibility(FillLayer layer, RCTMGLStyleValue styleValue) {
- layer.setProperties(PropertyFactory.visibility(styleValue.getString(VALUE_KEY)));
+ layer.setProperties(PropertyFactory.visibility(styleValue.getString(VALUE_KEY)));
}
public static void setFillAntialias(FillLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Boolean getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getBoolean(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Boolean value) {
- return PropertyFactory.fillAntialias(value);
- }
- };
-
- layer.setProperties(PropertyFactory.fillAntialias(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.fillAntialias(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.fillAntialias(styleValue.getBoolean(VALUE_KEY)));
}
}
public static void setFillOpacity(FillLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.fillOpacity(value);
- }
- };
-
- layer.setProperties(PropertyFactory.fillOpacity(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.fillOpacity(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.fillOpacity(styleValue.getFloat(VALUE_KEY)));
}
@@ -703,20 +676,8 @@ public static void setFillOpacityTransition(FillLayer layer, RCTMGLStyleValue st
}
public static void setFillColor(FillLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Integer getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getInt(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Integer value) {
- return PropertyFactory.fillColor(value);
- }
- };
-
- layer.setProperties(PropertyFactory.fillColor(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.fillColor(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.fillColor(styleValue.getInt(VALUE_KEY)));
}
@@ -731,20 +692,8 @@ public static void setFillColorTransition(FillLayer layer, RCTMGLStyleValue styl
}
public static void setFillOutlineColor(FillLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Integer getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getInt(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Integer value) {
- return PropertyFactory.fillOutlineColor(value);
- }
- };
-
- layer.setProperties(PropertyFactory.fillOutlineColor(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.fillOutlineColor(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.fillOutlineColor(styleValue.getInt(VALUE_KEY)));
}
@@ -759,20 +708,8 @@ public static void setFillOutlineColorTransition(FillLayer layer, RCTMGLStyleVal
}
public static void setFillTranslate(FillLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float[] getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloatArray(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float[] value) {
- return PropertyFactory.fillTranslate(value);
- }
- };
-
- layer.setProperties(PropertyFactory.fillTranslate(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.fillTranslate(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.fillTranslate(styleValue.getFloatArray(VALUE_KEY)));
}
@@ -787,40 +724,16 @@ public static void setFillTranslateTransition(FillLayer layer, RCTMGLStyleValue
}
public static void setFillTranslateAnchor(FillLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected String getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getString(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(String value) {
- return PropertyFactory.fillTranslateAnchor(value);
- }
- };
-
- layer.setProperties(PropertyFactory.fillTranslateAnchor(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.fillTranslateAnchor(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.fillTranslateAnchor(styleValue.getString(VALUE_KEY)));
}
}
public static void setFillPattern(FillLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected String getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getString(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(String value) {
- return PropertyFactory.fillPattern(value);
- }
- };
-
- layer.setProperties(PropertyFactory.fillPattern(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.fillPattern(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.fillPattern(styleValue.getString(VALUE_KEY)));
}
@@ -835,104 +748,44 @@ public static void setFillPatternTransition(FillLayer layer, RCTMGLStyleValue st
}
public static void setLineCap(LineLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected String getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getString(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(String value) {
- return PropertyFactory.lineCap(value);
- }
- };
-
- layer.setProperties(PropertyFactory.lineCap(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.lineCap(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.lineCap(styleValue.getString(VALUE_KEY)));
}
}
public static void setLineJoin(LineLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected String getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getString(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(String value) {
- return PropertyFactory.lineJoin(value);
- }
- };
-
- layer.setProperties(PropertyFactory.lineJoin(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.lineJoin(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.lineJoin(styleValue.getString(VALUE_KEY)));
}
}
public static void setLineMiterLimit(LineLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.lineMiterLimit(value);
- }
- };
-
- layer.setProperties(PropertyFactory.lineMiterLimit(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.lineMiterLimit(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.lineMiterLimit(styleValue.getFloat(VALUE_KEY)));
}
}
public static void setLineRoundLimit(LineLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.lineRoundLimit(value);
- }
- };
-
- layer.setProperties(PropertyFactory.lineRoundLimit(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.lineRoundLimit(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.lineRoundLimit(styleValue.getFloat(VALUE_KEY)));
}
}
public static void setVisibility(LineLayer layer, RCTMGLStyleValue styleValue) {
- layer.setProperties(PropertyFactory.visibility(styleValue.getString(VALUE_KEY)));
+ layer.setProperties(PropertyFactory.visibility(styleValue.getString(VALUE_KEY)));
}
public static void setLineOpacity(LineLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.lineOpacity(value);
- }
- };
-
- layer.setProperties(PropertyFactory.lineOpacity(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.lineOpacity(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.lineOpacity(styleValue.getFloat(VALUE_KEY)));
}
@@ -947,20 +800,8 @@ public static void setLineOpacityTransition(LineLayer layer, RCTMGLStyleValue st
}
public static void setLineColor(LineLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Integer getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getInt(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Integer value) {
- return PropertyFactory.lineColor(value);
- }
- };
-
- layer.setProperties(PropertyFactory.lineColor(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.lineColor(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.lineColor(styleValue.getInt(VALUE_KEY)));
}
@@ -975,20 +816,8 @@ public static void setLineColorTransition(LineLayer layer, RCTMGLStyleValue styl
}
public static void setLineTranslate(LineLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float[] getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloatArray(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float[] value) {
- return PropertyFactory.lineTranslate(value);
- }
- };
-
- layer.setProperties(PropertyFactory.lineTranslate(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.lineTranslate(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.lineTranslate(styleValue.getFloatArray(VALUE_KEY)));
}
@@ -1003,40 +832,16 @@ public static void setLineTranslateTransition(LineLayer layer, RCTMGLStyleValue
}
public static void setLineTranslateAnchor(LineLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected String getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getString(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(String value) {
- return PropertyFactory.lineTranslateAnchor(value);
- }
- };
-
- layer.setProperties(PropertyFactory.lineTranslateAnchor(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.lineTranslateAnchor(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.lineTranslateAnchor(styleValue.getString(VALUE_KEY)));
}
}
public static void setLineWidth(LineLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.lineWidth(value);
- }
- };
-
- layer.setProperties(PropertyFactory.lineWidth(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.lineWidth(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.lineWidth(styleValue.getFloat(VALUE_KEY)));
}
@@ -1051,20 +856,8 @@ public static void setLineWidthTransition(LineLayer layer, RCTMGLStyleValue styl
}
public static void setLineGapWidth(LineLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.lineGapWidth(value);
- }
- };
-
- layer.setProperties(PropertyFactory.lineGapWidth(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.lineGapWidth(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.lineGapWidth(styleValue.getFloat(VALUE_KEY)));
}
@@ -1079,20 +872,8 @@ public static void setLineGapWidthTransition(LineLayer layer, RCTMGLStyleValue s
}
public static void setLineOffset(LineLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.lineOffset(value);
- }
- };
-
- layer.setProperties(PropertyFactory.lineOffset(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.lineOffset(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.lineOffset(styleValue.getFloat(VALUE_KEY)));
}
@@ -1107,20 +888,8 @@ public static void setLineOffsetTransition(LineLayer layer, RCTMGLStyleValue sty
}
public static void setLineBlur(LineLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.lineBlur(value);
- }
- };
-
- layer.setProperties(PropertyFactory.lineBlur(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.lineBlur(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.lineBlur(styleValue.getFloat(VALUE_KEY)));
}
@@ -1135,20 +904,8 @@ public static void setLineBlurTransition(LineLayer layer, RCTMGLStyleValue style
}
public static void setLineDasharray(LineLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float[] getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloatArray(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float[] value) {
- return PropertyFactory.lineDasharray(value);
- }
- };
-
- layer.setProperties(PropertyFactory.lineDasharray(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.lineDasharray(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.lineDasharray(styleValue.getFloatArray(VALUE_KEY)));
}
@@ -1163,20 +920,8 @@ public static void setLineDasharrayTransition(LineLayer layer, RCTMGLStyleValue
}
public static void setLinePattern(LineLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected String getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getString(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(String value) {
- return PropertyFactory.linePattern(value);
- }
- };
-
- layer.setProperties(PropertyFactory.linePattern(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.linePattern(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.linePattern(styleValue.getString(VALUE_KEY)));
}
@@ -1191,744 +936,300 @@ public static void setLinePatternTransition(LineLayer layer, RCTMGLStyleValue st
}
public static void setSymbolPlacement(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected String getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getString(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(String value) {
- return PropertyFactory.symbolPlacement(value);
- }
- };
-
- layer.setProperties(PropertyFactory.symbolPlacement(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.symbolPlacement(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.symbolPlacement(styleValue.getString(VALUE_KEY)));
}
}
public static void setSymbolSpacing(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.symbolSpacing(value);
- }
- };
-
- layer.setProperties(PropertyFactory.symbolSpacing(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.symbolSpacing(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.symbolSpacing(styleValue.getFloat(VALUE_KEY)));
}
}
public static void setSymbolAvoidEdges(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Boolean getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getBoolean(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Boolean value) {
- return PropertyFactory.symbolAvoidEdges(value);
- }
- };
-
- layer.setProperties(PropertyFactory.symbolAvoidEdges(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.symbolAvoidEdges(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.symbolAvoidEdges(styleValue.getBoolean(VALUE_KEY)));
}
}
public static void setIconAllowOverlap(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Boolean getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getBoolean(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Boolean value) {
- return PropertyFactory.iconAllowOverlap(value);
- }
- };
-
- layer.setProperties(PropertyFactory.iconAllowOverlap(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.iconAllowOverlap(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconAllowOverlap(styleValue.getBoolean(VALUE_KEY)));
}
}
public static void setIconIgnorePlacement(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Boolean getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getBoolean(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Boolean value) {
- return PropertyFactory.iconIgnorePlacement(value);
- }
- };
-
- layer.setProperties(PropertyFactory.iconIgnorePlacement(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.iconIgnorePlacement(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconIgnorePlacement(styleValue.getBoolean(VALUE_KEY)));
}
}
public static void setIconOptional(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Boolean getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getBoolean(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Boolean value) {
- return PropertyFactory.iconOptional(value);
- }
- };
-
- layer.setProperties(PropertyFactory.iconOptional(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.iconOptional(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconOptional(styleValue.getBoolean(VALUE_KEY)));
}
}
public static void setIconRotationAlignment(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected String getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getString(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(String value) {
- return PropertyFactory.iconRotationAlignment(value);
- }
- };
-
- layer.setProperties(PropertyFactory.iconRotationAlignment(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.iconRotationAlignment(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconRotationAlignment(styleValue.getString(VALUE_KEY)));
}
}
public static void setIconSize(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.iconSize(value);
- }
- };
-
- layer.setProperties(PropertyFactory.iconSize(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.iconSize(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconSize(styleValue.getFloat(VALUE_KEY)));
}
}
public static void setIconTextFit(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected String getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getString(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(String value) {
- return PropertyFactory.iconTextFit(value);
- }
- };
-
- layer.setProperties(PropertyFactory.iconTextFit(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.iconTextFit(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconTextFit(styleValue.getString(VALUE_KEY)));
}
}
public static void setIconTextFitPadding(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float[] getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloatArray(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float[] value) {
- return PropertyFactory.iconTextFitPadding(value);
- }
- };
-
- layer.setProperties(PropertyFactory.iconTextFitPadding(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.iconTextFitPadding(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconTextFitPadding(styleValue.getFloatArray(VALUE_KEY)));
}
}
public static void setIconImage(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected String getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getString(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(String value) {
- return PropertyFactory.iconImage(value);
- }
- };
-
- layer.setProperties(PropertyFactory.iconImage(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.iconImage(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconImage(styleValue.getString(VALUE_KEY)));
}
}
public static void setIconRotate(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.iconRotate(value);
- }
- };
-
- layer.setProperties(PropertyFactory.iconRotate(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.iconRotate(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconRotate(styleValue.getFloat(VALUE_KEY)));
}
}
public static void setIconPadding(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.iconPadding(value);
- }
- };
-
- layer.setProperties(PropertyFactory.iconPadding(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.iconPadding(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconPadding(styleValue.getFloat(VALUE_KEY)));
}
}
public static void setIconKeepUpright(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Boolean getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getBoolean(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Boolean value) {
- return PropertyFactory.iconKeepUpright(value);
- }
- };
-
- layer.setProperties(PropertyFactory.iconKeepUpright(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.iconKeepUpright(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconKeepUpright(styleValue.getBoolean(VALUE_KEY)));
}
}
public static void setIconOffset(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float[] getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloatArray(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float[] value) {
- return PropertyFactory.iconOffset(value);
- }
- };
-
- layer.setProperties(PropertyFactory.iconOffset(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.iconOffset(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconOffset(styleValue.getFloatArray(VALUE_KEY)));
}
}
public static void setIconAnchor(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected String getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getString(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(String value) {
- return PropertyFactory.iconAnchor(value);
- }
- };
-
- layer.setProperties(PropertyFactory.iconAnchor(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.iconAnchor(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconAnchor(styleValue.getString(VALUE_KEY)));
}
}
public static void setIconPitchAlignment(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected String getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getString(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(String value) {
- return PropertyFactory.iconPitchAlignment(value);
- }
- };
-
- layer.setProperties(PropertyFactory.iconPitchAlignment(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.iconPitchAlignment(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconPitchAlignment(styleValue.getString(VALUE_KEY)));
}
}
public static void setTextPitchAlignment(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected String getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getString(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(String value) {
- return PropertyFactory.textPitchAlignment(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textPitchAlignment(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textPitchAlignment(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textPitchAlignment(styleValue.getString(VALUE_KEY)));
}
}
public static void setTextRotationAlignment(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected String getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getString(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(String value) {
- return PropertyFactory.textRotationAlignment(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textRotationAlignment(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textRotationAlignment(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textRotationAlignment(styleValue.getString(VALUE_KEY)));
}
}
public static void setTextField(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected String getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getString(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(String value) {
- return PropertyFactory.textField(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textField(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textField(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textField(styleValue.getString(VALUE_KEY)));
}
}
public static void setTextFont(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected String[] getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getStringArray(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(String[] value) {
- return PropertyFactory.textFont(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textFont(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textFont(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textFont(styleValue.getStringArray(VALUE_KEY)));
}
}
public static void setTextSize(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.textSize(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textSize(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textSize(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textSize(styleValue.getFloat(VALUE_KEY)));
}
}
public static void setTextMaxWidth(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.textMaxWidth(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textMaxWidth(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textMaxWidth(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textMaxWidth(styleValue.getFloat(VALUE_KEY)));
}
}
public static void setTextLineHeight(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.textLineHeight(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textLineHeight(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textLineHeight(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textLineHeight(styleValue.getFloat(VALUE_KEY)));
}
}
public static void setTextLetterSpacing(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.textLetterSpacing(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textLetterSpacing(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textLetterSpacing(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textLetterSpacing(styleValue.getFloat(VALUE_KEY)));
}
}
public static void setTextJustify(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected String getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getString(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(String value) {
- return PropertyFactory.textJustify(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textJustify(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textJustify(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textJustify(styleValue.getString(VALUE_KEY)));
}
}
public static void setTextAnchor(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected String getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getString(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(String value) {
- return PropertyFactory.textAnchor(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textAnchor(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textAnchor(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textAnchor(styleValue.getString(VALUE_KEY)));
}
}
public static void setTextMaxAngle(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.textMaxAngle(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textMaxAngle(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textMaxAngle(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textMaxAngle(styleValue.getFloat(VALUE_KEY)));
}
}
public static void setTextRotate(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.textRotate(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textRotate(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textRotate(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textRotate(styleValue.getFloat(VALUE_KEY)));
}
}
public static void setTextPadding(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.textPadding(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textPadding(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textPadding(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textPadding(styleValue.getFloat(VALUE_KEY)));
}
}
public static void setTextKeepUpright(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Boolean getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getBoolean(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Boolean value) {
- return PropertyFactory.textKeepUpright(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textKeepUpright(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textKeepUpright(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textKeepUpright(styleValue.getBoolean(VALUE_KEY)));
}
}
public static void setTextTransform(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected String getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getString(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(String value) {
- return PropertyFactory.textTransform(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textTransform(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textTransform(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textTransform(styleValue.getString(VALUE_KEY)));
}
}
public static void setTextOffset(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float[] getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloatArray(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float[] value) {
- return PropertyFactory.textOffset(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textOffset(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textOffset(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textOffset(styleValue.getFloatArray(VALUE_KEY)));
}
}
public static void setTextAllowOverlap(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Boolean getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getBoolean(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Boolean value) {
- return PropertyFactory.textAllowOverlap(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textAllowOverlap(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textAllowOverlap(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textAllowOverlap(styleValue.getBoolean(VALUE_KEY)));
}
}
public static void setTextIgnorePlacement(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Boolean getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getBoolean(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Boolean value) {
- return PropertyFactory.textIgnorePlacement(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textIgnorePlacement(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textIgnorePlacement(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textIgnorePlacement(styleValue.getBoolean(VALUE_KEY)));
}
}
public static void setTextOptional(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Boolean getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getBoolean(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Boolean value) {
- return PropertyFactory.textOptional(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textOptional(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textOptional(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textOptional(styleValue.getBoolean(VALUE_KEY)));
}
}
public static void setVisibility(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- layer.setProperties(PropertyFactory.visibility(styleValue.getString(VALUE_KEY)));
+ layer.setProperties(PropertyFactory.visibility(styleValue.getString(VALUE_KEY)));
}
public static void setIconOpacity(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.iconOpacity(value);
- }
- };
-
- layer.setProperties(PropertyFactory.iconOpacity(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.iconOpacity(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconOpacity(styleValue.getFloat(VALUE_KEY)));
}
@@ -1943,20 +1244,8 @@ public static void setIconOpacityTransition(SymbolLayer layer, RCTMGLStyleValue
}
public static void setIconColor(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Integer getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getInt(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Integer value) {
- return PropertyFactory.iconColor(value);
- }
- };
-
- layer.setProperties(PropertyFactory.iconColor(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.iconColor(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconColor(styleValue.getInt(VALUE_KEY)));
}
@@ -1971,20 +1260,8 @@ public static void setIconColorTransition(SymbolLayer layer, RCTMGLStyleValue st
}
public static void setIconHaloColor(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Integer getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getInt(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Integer value) {
- return PropertyFactory.iconHaloColor(value);
- }
- };
-
- layer.setProperties(PropertyFactory.iconHaloColor(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.iconHaloColor(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconHaloColor(styleValue.getInt(VALUE_KEY)));
}
@@ -1999,20 +1276,8 @@ public static void setIconHaloColorTransition(SymbolLayer layer, RCTMGLStyleValu
}
public static void setIconHaloWidth(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.iconHaloWidth(value);
- }
- };
-
- layer.setProperties(PropertyFactory.iconHaloWidth(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.iconHaloWidth(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconHaloWidth(styleValue.getFloat(VALUE_KEY)));
}
@@ -2027,20 +1292,8 @@ public static void setIconHaloWidthTransition(SymbolLayer layer, RCTMGLStyleValu
}
public static void setIconHaloBlur(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.iconHaloBlur(value);
- }
- };
-
- layer.setProperties(PropertyFactory.iconHaloBlur(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.iconHaloBlur(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconHaloBlur(styleValue.getFloat(VALUE_KEY)));
}
@@ -2055,20 +1308,8 @@ public static void setIconHaloBlurTransition(SymbolLayer layer, RCTMGLStyleValue
}
public static void setIconTranslate(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float[] getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloatArray(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float[] value) {
- return PropertyFactory.iconTranslate(value);
- }
- };
-
- layer.setProperties(PropertyFactory.iconTranslate(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.iconTranslate(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconTranslate(styleValue.getFloatArray(VALUE_KEY)));
}
@@ -2083,40 +1324,16 @@ public static void setIconTranslateTransition(SymbolLayer layer, RCTMGLStyleValu
}
public static void setIconTranslateAnchor(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected String getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getString(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(String value) {
- return PropertyFactory.iconTranslateAnchor(value);
- }
- };
-
- layer.setProperties(PropertyFactory.iconTranslateAnchor(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.iconTranslateAnchor(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconTranslateAnchor(styleValue.getString(VALUE_KEY)));
}
}
public static void setTextOpacity(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.textOpacity(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textOpacity(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textOpacity(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textOpacity(styleValue.getFloat(VALUE_KEY)));
}
@@ -2131,20 +1348,8 @@ public static void setTextOpacityTransition(SymbolLayer layer, RCTMGLStyleValue
}
public static void setTextColor(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Integer getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getInt(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Integer value) {
- return PropertyFactory.textColor(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textColor(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textColor(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textColor(styleValue.getInt(VALUE_KEY)));
}
@@ -2159,20 +1364,8 @@ public static void setTextColorTransition(SymbolLayer layer, RCTMGLStyleValue st
}
public static void setTextHaloColor(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Integer getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getInt(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Integer value) {
- return PropertyFactory.textHaloColor(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textHaloColor(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textHaloColor(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textHaloColor(styleValue.getInt(VALUE_KEY)));
}
@@ -2187,20 +1380,8 @@ public static void setTextHaloColorTransition(SymbolLayer layer, RCTMGLStyleValu
}
public static void setTextHaloWidth(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.textHaloWidth(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textHaloWidth(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textHaloWidth(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textHaloWidth(styleValue.getFloat(VALUE_KEY)));
}
@@ -2215,20 +1396,8 @@ public static void setTextHaloWidthTransition(SymbolLayer layer, RCTMGLStyleValu
}
public static void setTextHaloBlur(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.textHaloBlur(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textHaloBlur(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textHaloBlur(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textHaloBlur(styleValue.getFloat(VALUE_KEY)));
}
@@ -2243,20 +1412,8 @@ public static void setTextHaloBlurTransition(SymbolLayer layer, RCTMGLStyleValue
}
public static void setTextTranslate(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float[] getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloatArray(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float[] value) {
- return PropertyFactory.textTranslate(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textTranslate(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textTranslate(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textTranslate(styleValue.getFloatArray(VALUE_KEY)));
}
@@ -2271,44 +1428,20 @@ public static void setTextTranslateTransition(SymbolLayer layer, RCTMGLStyleValu
}
public static void setTextTranslateAnchor(SymbolLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected String getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getString(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(String value) {
- return PropertyFactory.textTranslateAnchor(value);
- }
- };
-
- layer.setProperties(PropertyFactory.textTranslateAnchor(styleValue.makeCameraFunction(styleValue.getInt("mode"), parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.textTranslateAnchor(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.textTranslateAnchor(styleValue.getString(VALUE_KEY)));
}
}
public static void setVisibility(CircleLayer layer, RCTMGLStyleValue styleValue) {
- layer.setProperties(PropertyFactory.visibility(styleValue.getString(VALUE_KEY)));
+ layer.setProperties(PropertyFactory.visibility(styleValue.getString(VALUE_KEY)));
}
public static void setCircleRadius(CircleLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser parser = new RCTMGLStyleFunctionParser(styleValue) {
- @Override
- protected Float getRawStopValue(RCTMGLStyleValue styleValue) {
- return styleValue.getFloat(VALUE_KEY);
- }
-
- @Override
- protected PropertyValue getStopValue(Float value) {
- return PropertyFactory.circleRadius(value);
- }
- };
-
- layer.setProperties(PropertyFactory.circleRadius(styleValue.makeStyleFunction(parser)));
+ if (styleValue.isExpression()) {
+ layer.setProperties(PropertyFactory.circleRadius(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.circleRadius(styleValue.getFloat(VALUE_KEY)));
}
@@ -2323,20 +1456,8 @@ public static void setCircleRadiusTransition(CircleLayer layer, RCTMGLStyleValue
}
public static void setCircleColor(CircleLayer layer, RCTMGLStyleValue styleValue) {
- if (styleValue.isFunction()) {
- RCTMGLStyleFunctionParser