Search in sources :

Example 16 with AndroidCallbackEvent

use of com.mapbox.rctmgl.events.AndroidCallbackEvent in project maps by rnmapbox.

the class RCTMGLShapeSource method getClusterLeavesById.

// Deprecated. Will be removed in 9+ ver.
public void getClusterLeavesById(String callbackID, int clusterId, int number, int offset) {
    if (mSource == null) {
        WritableMap payload = new WritableNativeMap();
        payload.putString("error", "source is not yet loaded");
        AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload);
        mManager.handleEvent(event);
        return;
    }
    Feature clusterFeature = mSource.querySourceFeatures(Expression.eq(Expression.get("cluster_id"), clusterId)).get(0);
    FeatureCollection leaves = mSource.getClusterLeaves(clusterFeature, number, offset);
    WritableMap payload = new WritableNativeMap();
    payload.putString("data", leaves.toJson());
    AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload);
    mManager.handleEvent(event);
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) FeatureCollection(com.mapbox.geojson.FeatureCollection) WritableNativeMap(com.facebook.react.bridge.WritableNativeMap) Feature(com.mapbox.geojson.Feature) AndroidCallbackEvent(com.mapbox.rctmgl.events.AndroidCallbackEvent)

Example 17 with AndroidCallbackEvent

use of com.mapbox.rctmgl.events.AndroidCallbackEvent in project maps by rnmapbox.

the class RCTMGLShapeSource method getClusterLeaves.

public void getClusterLeaves(String callbackID, String featureJSON, int number, int offset) {
    if (mSource == null) {
        WritableMap payload = new WritableNativeMap();
        payload.putString("error", "source is not yet loaded");
        AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload);
        mManager.handleEvent(event);
        return;
    }
    Feature clusterFeature = Feature.fromJson(featureJSON);
    FeatureCollection leaves = mSource.getClusterLeaves(clusterFeature, number, offset);
    WritableMap payload = new WritableNativeMap();
    payload.putString("data", leaves.toJson());
    AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload);
    mManager.handleEvent(event);
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) FeatureCollection(com.mapbox.geojson.FeatureCollection) WritableNativeMap(com.facebook.react.bridge.WritableNativeMap) Feature(com.mapbox.geojson.Feature) AndroidCallbackEvent(com.mapbox.rctmgl.events.AndroidCallbackEvent)

Example 18 with AndroidCallbackEvent

use of com.mapbox.rctmgl.events.AndroidCallbackEvent in project maps by rnmapbox.

the class RCTMGLVectorSource method querySourceFeatures.

public void querySourceFeatures(String callbackID, @Size(min = 1) List<String> layerIDs, @Nullable Expression filter) {
    if (mSource == null) {
        WritableMap payload = new WritableNativeMap();
        payload.putString("error", "source is not yet loaded");
        AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload);
        mManager.handleEvent(event);
        return;
    }
    List<Feature> features = mSource.querySourceFeatures(layerIDs.toArray(new String[layerIDs.size()]), filter);
    WritableMap payload = new WritableNativeMap();
    payload.putString("data", FeatureCollection.fromFeatures(features).toJson());
    AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload);
    mManager.handleEvent(event);
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) WritableNativeMap(com.facebook.react.bridge.WritableNativeMap) Feature(com.mapbox.geojson.Feature) AndroidCallbackEvent(com.mapbox.rctmgl.events.AndroidCallbackEvent)

Example 19 with AndroidCallbackEvent

use of com.mapbox.rctmgl.events.AndroidCallbackEvent in project maps by rnmapbox.

the class RCTMGLShapeSource method callbackError.

private void callbackError(String callbackID, String error, String where) {
    WritableMap payload = new WritableNativeMap();
    payload.putString("error", where + ": " + error);
    AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload);
    mManager.handleEvent(event);
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) WritableNativeMap(com.facebook.react.bridge.WritableNativeMap) AndroidCallbackEvent(com.mapbox.rctmgl.events.AndroidCallbackEvent)

Aggregations

WritableMap (com.facebook.react.bridge.WritableMap)19 WritableNativeMap (com.facebook.react.bridge.WritableNativeMap)19 AndroidCallbackEvent (com.mapbox.rctmgl.events.AndroidCallbackEvent)19 Feature (com.mapbox.geojson.Feature)10 FeatureCollection (com.mapbox.geojson.FeatureCollection)4 WritableArray (com.facebook.react.bridge.WritableArray)3 WritableNativeArray (com.facebook.react.bridge.WritableNativeArray)3 LatLng (com.mapbox.mapboxsdk.geometry.LatLng)2 QueriedFeature (com.mapbox.maps.QueriedFeature)2 QueryFeaturesCallback (com.mapbox.maps.QueryFeaturesCallback)2 SourceQueryOptions (com.mapbox.maps.SourceQueryOptions)2 AbstractMapFeature (com.mapbox.rctmgl.components.AbstractMapFeature)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 PointF (android.graphics.PointF)1 NonNull (androidx.annotation.NonNull)1 Expected (com.mapbox.bindgen.Expected)1 CameraPosition (com.mapbox.mapboxsdk.camera.CameraPosition)1 VisibleRegion (com.mapbox.mapboxsdk.geometry.VisibleRegion)1 QueryFeatureExtensionCallback (com.mapbox.maps.QueryFeatureExtensionCallback)1