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