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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations