Search in sources :

Example 6 with AndroidCallbackEvent

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

the class RCTMGLMapView method getCoordinateFromView.

public void getCoordinateFromView(String callbackID, PointF pointInView) {
    float density = getDisplayDensity();
    pointInView.x *= density;
    pointInView.y *= density;
    LatLng mapCoordinate = mMap.getProjection().fromScreenLocation(pointInView);
    WritableMap payload = new WritableNativeMap();
    WritableArray array = new WritableNativeArray();
    array.pushDouble(mapCoordinate.getLongitude());
    array.pushDouble(mapCoordinate.getLatitude());
    payload.putArray("coordinateFromView", 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) WritableNativeMap(com.facebook.react.bridge.WritableNativeMap) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) WritableNativeArray(com.facebook.react.bridge.WritableNativeArray) AndroidCallbackEvent(com.mapbox.rctmgl.events.AndroidCallbackEvent)

Example 7 with AndroidCallbackEvent

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

the class RCTMGLShapeSource method getClusterChildrenById.

// Deprecated. Will be removed in 9+ ver.
public void getClusterChildrenById(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;
    }
    Feature clusterFeature = mSource.querySourceFeatures(Expression.eq(Expression.get("cluster_id"), clusterId)).get(0);
    FeatureCollection leaves = mSource.getClusterChildren(clusterFeature);
    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 8 with AndroidCallbackEvent

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

the class RCTMGLShapeSource method getClusterChildren.

public void getClusterChildren(String callbackID, String featureJSON) {
    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.getClusterChildren(clusterFeature);
    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 9 with AndroidCallbackEvent

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

the class RCTMGLShapeSource method getClusterExpansionZoom.

public void getClusterExpansionZoom(String callbackID, String featureJSON) {
    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 feature = Feature.fromJson(featureJSON);
    int zoom = mSource.getClusterExpansionZoom(feature);
    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 10 with AndroidCallbackEvent

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

the class RCTMGLMapView method queryTerrainElevation.

public void queryTerrainElevation(String callbackID, double longitude, double latitude) {
    Double result = mMap.getElevation(Point.fromLngLat(longitude, latitude));
    WritableMap payload = new WritableNativeMap();
    payload.putDouble("data", result);
    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