[android] - add API to perform platform side animations
This commit is contained in:
committed by
Tobrun
parent
7bcb3232cc
commit
2f4cc7e466
@@ -148,7 +148,8 @@ public class MapView extends FrameLayout {
|
||||
addOnMapChangedListener(mapCallback);
|
||||
|
||||
// callback for focal point invalidation
|
||||
final FocalPointInvalidator focalPointInvalidator = new FocalPointInvalidator(createFocalPointChangeListener());
|
||||
final FocalPointInvalidator focalPointInvalidator = new FocalPointInvalidator();
|
||||
focalPointInvalidator.addListener(createFocalPointChangeListener());
|
||||
|
||||
// callback for registering touch listeners
|
||||
RegisterTouchListener registerTouchListener = new RegisterTouchListener();
|
||||
@@ -177,8 +178,11 @@ public class MapView extends FrameLayout {
|
||||
markerViewManager, iconManager, annotations, markers, polygons, polylines);
|
||||
Transform transform = new Transform(nativeMapView, annotationManager.getMarkerViewManager(), trackingSettings,
|
||||
cameraChangeDispatcher);
|
||||
|
||||
mapboxMap = new MapboxMap(nativeMapView, transform, uiSettings, trackingSettings, myLocationViewSettings, proj,
|
||||
registerTouchListener, annotationManager, cameraChangeDispatcher);
|
||||
focalPointInvalidator.addListener(mapboxMap.createFocalPointChangeListener());
|
||||
|
||||
mapCallback.attachMapboxMap(mapboxMap);
|
||||
|
||||
// user input
|
||||
@@ -817,10 +821,10 @@ public class MapView extends FrameLayout {
|
||||
|
||||
private class FocalPointInvalidator implements FocalPointChangeListener {
|
||||
|
||||
private final FocalPointChangeListener[] focalPointChangeListeners;
|
||||
private final List<FocalPointChangeListener> focalPointChangeListeners = new ArrayList<>();
|
||||
|
||||
FocalPointInvalidator(FocalPointChangeListener... listeners) {
|
||||
focalPointChangeListeners = listeners;
|
||||
void addListener(FocalPointChangeListener focalPointChangeListener) {
|
||||
focalPointChangeListeners.add(focalPointChangeListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -75,6 +75,7 @@ public final class MapboxMap {
|
||||
private final OnRegisterTouchListener onRegisterTouchListener;
|
||||
|
||||
private MapboxMap.OnFpsChangedListener onFpsChangedListener;
|
||||
private PointF focalPoint;
|
||||
|
||||
MapboxMap(NativeMapView map, Transform transform, UiSettings ui, TrackingSettings tracking,
|
||||
MyLocationViewSettings myLocationView, Projection projection, OnRegisterTouchListener listener,
|
||||
@@ -611,6 +612,47 @@ public final class MapboxMap {
|
||||
// Camera API
|
||||
//
|
||||
|
||||
/**
|
||||
* Moves the center of the screen to a latitude and longitude specified by a LatLng object. This centers the
|
||||
* camera on the LatLng object.
|
||||
*
|
||||
* @param latLng Target location to change to
|
||||
*/
|
||||
public void setLatLng(@NonNull LatLng latLng) {
|
||||
nativeMapView.setLatLng(latLng);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the camera viewpoint to a particular zoom level.
|
||||
*
|
||||
* @param zoom Zoom level to change to
|
||||
*/
|
||||
public void setZoom(@FloatRange(from = MapboxConstants.MINIMUM_ZOOM, to = MapboxConstants.MAXIMUM_ZOOM) double zoom) {
|
||||
if (focalPoint == null) {
|
||||
focalPoint = new PointF(nativeMapView.getWidth() / 2, nativeMapView.getHeight() / 2);
|
||||
}
|
||||
nativeMapView.setZoom(zoom, focalPoint, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the camera viewpoint angle to a particular angle in degrees.
|
||||
*
|
||||
* @param tilt Tilt angle to change to
|
||||
*/
|
||||
public void setTilt(@FloatRange(from = MapboxConstants.MINIMUM_TILT, to = MapboxConstants.MAXIMUM_TILT) double tilt) {
|
||||
nativeMapView.setPitch(tilt, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the camera viewpoint direction to a particular angle in degrees.
|
||||
*
|
||||
* @param bearing Direction angle to change to
|
||||
*/
|
||||
public void setBearing(@FloatRange(from = MapboxConstants.MINIMUM_DIRECTION, to = MapboxConstants.MAXIMUM_DIRECTION)
|
||||
double bearing) {
|
||||
nativeMapView.setBearing(bearing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels ongoing animations.
|
||||
* <p>
|
||||
@@ -1986,6 +2028,15 @@ public final class MapboxMap {
|
||||
return nativeMapView.queryRenderedFeatures(coordinates, layerIds, filter);
|
||||
}
|
||||
|
||||
FocalPointChangeListener createFocalPointChangeListener() {
|
||||
return new FocalPointChangeListener() {
|
||||
@Override
|
||||
public void onFocalPointChanged(PointF pointF) {
|
||||
focalPoint = pointF;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//
|
||||
// Interfaces
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user