Search in sources :

Example 11 with AndroidCallbackEvent

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

the class RCTMGLMapView method queryRenderedFeaturesAtPoint.

public void queryRenderedFeaturesAtPoint(String callbackID, PointF point, Expression filter, List<String> layerIDs) {
    List<Feature> features = mMap.queryRenderedFeatures(point, filter, layerIDs.toArray(new String[layerIDs.size()]));
    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) AbstractMapFeature(com.mapbox.rctmgl.components.AbstractMapFeature) AndroidCallbackEvent(com.mapbox.rctmgl.events.AndroidCallbackEvent)

Example 12 with AndroidCallbackEvent

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

the class RCTMGLMapView method getVisibleBounds.

public void getVisibleBounds(String callbackID) {
    VisibleRegion region = mMap.getProjection().getVisibleRegion();
    WritableMap payload = new WritableNativeMap();
    payload.putArray("visibleBounds", GeoJSONUtils.fromLatLngBounds(region.latLngBounds));
    AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload);
    mManager.handleEvent(event);
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) VisibleRegion(com.mapbox.mapboxsdk.geometry.VisibleRegion) WritableNativeMap(com.facebook.react.bridge.WritableNativeMap) AndroidCallbackEvent(com.mapbox.rctmgl.events.AndroidCallbackEvent)

Example 13 with AndroidCallbackEvent

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

the class RCTMGLMapView method getPointInView.

public void getPointInView(String callbackID, LatLng mapCoordinate) {
    PointF pointInView = mMap.getProjection().toScreenLocation(mapCoordinate);
    float density = getDisplayDensity();
    pointInView.x /= density;
    pointInView.y /= density;
    WritableMap payload = new WritableNativeMap();
    WritableArray array = new WritableNativeArray();
    array.pushDouble(pointInView.x);
    array.pushDouble(pointInView.y);
    payload.putArray("pointInView", array);
    AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload);
    mManager.handleEvent(event);
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) WritableArray(com.facebook.react.bridge.WritableArray) PointF(android.graphics.PointF) WritableNativeMap(com.facebook.react.bridge.WritableNativeMap) WritableNativeArray(com.facebook.react.bridge.WritableNativeArray) AndroidCallbackEvent(com.mapbox.rctmgl.events.AndroidCallbackEvent)

Example 14 with AndroidCallbackEvent

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

the class RCTMGLShapeSource method getClusterExpansionZoomById.

// Deprecated. Will be removed in 9+ ver.
public void getClusterExpansionZoomById(String callbackID, int clusterId) {
    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(Expression.eq(Expression.id(), clusterId));
    int zoom = -1;
    if (features.size() > 0) {
        zoom = mSource.getClusterExpansionZoom(features.get(0));
    }
    if (zoom == -1) {
        WritableMap payload = new WritableNativeMap();
        payload.putString("error", "Could not get zoom for cluster id " + clusterId);
        AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload);
        mManager.handleEvent(event);
        return;
    }
    WritableMap payload = new WritableNativeMap();
    payload.putInt("data", zoom);
    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 15 with AndroidCallbackEvent

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

the class RCTMGLShapeSource method querySourceFeatures.

public void querySourceFeatures(String callbackID, @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(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)

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