[android] - remove camera api from MapboxMap, refactor test app code to CameraUpdateFactory api

This commit is contained in:
Tobrun
2018-02-14 12:36:23 +01:00
committed by Tobrun
parent 2e3145db47
commit d9e4c61923
5 changed files with 37 additions and 256 deletions

View File

@@ -148,6 +148,26 @@ public final class CameraUpdateFactory {
return new ZoomUpdate(ZoomUpdate.ZOOM_TO, zoom);
}
/**
* Returns a CameraUpdate that moves the camera viewpoint to a particular bearing.
*
* @param bearing Bearing to change to
* @return CameraUpdate Final Camera Position
*/
public static CameraUpdate bearingTo(double bearing) {
return new CameraPositionUpdate(bearing, null, -1, -1);
}
/**
* Returns a CameraUpdate that moves the camera viewpoint to a particular tilt.
*
* @param tilt Tilt to change to
* @return CameraUpdate Final Camera Position
*/
public static CameraUpdate tiltTo(double tilt) {
return new CameraPositionUpdate(-1, null, tilt, -1);
}
//
// CameraUpdate types
//

View File

@@ -16,6 +16,7 @@ import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import com.mapbox.android.core.location.LocationEngine;
import com.mapbox.geojson.Feature;
import com.mapbox.geojson.Geometry;
import com.mapbox.mapboxsdk.annotations.Annotation;
@@ -43,7 +44,6 @@ import com.mapbox.mapboxsdk.style.layers.Filter;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.light.Light;
import com.mapbox.mapboxsdk.style.sources.Source;
import com.mapbox.android.core.location.LocationEngine;
import java.lang.reflect.ParameterizedType;
import java.util.HashMap;
@@ -601,7 +601,7 @@ public final class MapboxMap {
}
//
//
// Light
//
/**
@@ -618,65 +618,6 @@ 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.
* <p>
* Note that at low zoom levels, setLatLng is constrained so that the entire viewport shows map data.
* </p>
*
* @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 center and the zoom of the camera specified by a LatLng object and double zoom.
* <p>
* Note that at low zoom levels, setLatLng is constrained so that the entire viewport shows map data.
* </p>
*
* @param latLng Target location to change to
*/
public void setLatLngZoom(@NonNull LatLng latLng,
@FloatRange(from = MapboxConstants.MINIMUM_ZOOM,
to = MapboxConstants.MAXIMUM_ZOOM) double zoom) {
setZoom(zoom);
setLatLng(latLng);
}
/**
* 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>