use of com.mapbox.rctmgl.utils.LatLng in project maps by rnmapbox.
the class RCTMGLCamera method getUserLocationUpdateCameraOptions.
private CameraOptions getUserLocationUpdateCameraOptions(double zoomLevel) {
LatLng center = mUserLocation.getCoordinate();
ScreenCoordinate anchor = CameraAnimationsUtils.getCamera(mMapView).getAnchor();
CameraState actState = mMapView.getMapboxMap().getCameraState();
if (mUserLocationVerticalAlignment != UserLocationVerticalAlignment.CENTER) {
CameraOptions options = ExtensionUtils.toCameraOptions(actState, anchor);
CoordinateBounds bounds = mMapView.getMapboxMap().coordinateBoundsForCamera(options);
switch(mUserLocationVerticalAlignment) {
case UserLocationVerticalAlignment.TOP:
center = new LatLng(bounds.getNortheast().latitude(), center.getLongitude());
break;
case UserLocationVerticalAlignment.BOTTOM:
center = new LatLng(bounds.getSouthwest().latitude(), center.getLongitude());
break;
}
}
return new CameraOptions.Builder().center(center.getPoint()).bearing(getDirectionForUserLocationUpdate()).pitch(mPitch).anchor(anchor).padding(actState.getPadding()).zoom(zoomLevel).build();
}
use of com.mapbox.rctmgl.utils.LatLng in project maps by rnmapbox.
the class RCTMGLMapView method onMapClick.
@Override
public boolean onMapClick(@NonNull Point point) {
RCTMGLMapView _this = this;
/*if (mPointAnnotationManager != nil) {
getAnnotations()
}*/
if (mAnnotationClicked) {
mAnnotationClicked = false;
return true;
}
ScreenCoordinate screenPoint = mMap.pixelForCoordinate(point);
List<RCTSource> touchableSources = getAllTouchableSources();
HashMap<String, List<Feature>> hits = new HashMap<>();
handleTapInSources(new LinkedList<>(touchableSources), screenPoint, hits, new ArrayList<>(), new HandleTap() {
@Override
public void run(List<RCTSource> hitTouchableSources, Map<String, List<Feature>> hits) {
if (hits.size() > 0) {
RCTSource source = getTouchableSourceWithHighestZIndex(hitTouchableSources);
if (source != null && source.hasPressListener()) {
source.onPress(new RCTSource.OnPressEvent(hits.get(source.getID()), GeoJSONUtils.toLatLng(point), new PointF((float) screenPoint.getX(), (float) screenPoint.getY())));
return;
}
}
MapClickEvent event = new MapClickEvent(_this, new LatLng(point), screenPoint);
mManager.handleEvent(event);
}
});
return false;
}
use of com.mapbox.rctmgl.utils.LatLng in project maps by rnmapbox.
the class GeoJSONUtils method fromCoordinateBounds.
public static WritableArray fromCoordinateBounds(CoordinateBounds bounds) {
WritableArray array = Arguments.createArray();
Point ne = bounds.getNortheast();
Point sw = bounds.getSouthwest();
LatLng[] latLngs = { new LatLng(ne.latitude(), ne.longitude()), new LatLng(ne.latitude(), sw.longitude()), new LatLng(sw.latitude(), sw.longitude()), new LatLng(sw.latitude(), ne.longitude()) };
for (LatLng latLng : latLngs) {
array.pushArray(fromLatLng(latLng));
}
return array;
}
Aggregations