use of com.mapbox.mapboxsdk.camera.CameraPosition in project mapbox-navigation-android by mapbox.
the class RerouteActivity method onProgressChange.
@Override
public void onProgressChange(Location location, RouteProgress routeProgress) {
if (tracking) {
locationLayerPlugin.forceLocationUpdate(location);
CameraPosition cameraPosition = new CameraPosition.Builder().zoom(15).target(new LatLng(location.getLatitude(), location.getLongitude())).bearing(location.getBearing()).build();
mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 2000);
}
}
use of com.mapbox.mapboxsdk.camera.CameraPosition in project mapbox-plugins-android by mapbox.
the class PlacePickerTest method getLastCameraPosition.
// TODO finish mocking this class
@Test
@Ignore
public void getLastCameraPosition() throws Exception {
CameraPosition cameraPosition = new CameraPosition.Builder().target(new LatLng(2.0, 3.0)).bearing(30).zoom(20).build();
Parcel parcel = mock(Parcel.class);
cameraPosition.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
Intent data = mock(Intent.class);
data.putExtra(PlaceConstants.MAP_CAMERA_POSITION, cameraPosition);
CameraPosition position = PlacePicker.getLastCameraPosition(data);
assertNotNull(position);
}
use of com.mapbox.mapboxsdk.camera.CameraPosition in project mapbox-plugins-android by mapbox.
the class CompassListenerActivity method onMapReady.
@Override
public void onMapReady(final MapboxMap mapboxMap) {
LocationEngine locationEngine = new LocationEngineProvider(this).obtainBestLocationEngineAvailable();
locationLayerPlugin = new LocationLayerPlugin(mapView, mapboxMap, locationEngine);
locationLayerPlugin.setRenderMode(RenderMode.COMPASS);
locationLayerPlugin.addCompassListener(new CompassListener() {
@Override
public void onCompassChanged(float userHeading) {
CameraPosition cameraPosition = new CameraPosition.Builder().bearing(userHeading).build();
mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
@Override
public void onCompassAccuracyChange(int compassStatus) {
Timber.v("Compass reading: %d", compassStatus);
}
});
}
use of com.mapbox.mapboxsdk.camera.CameraPosition in project mapbox-plugins-android by mapbox.
the class OfflineRegionDetailActivity method setupUI.
private void setupUI(final OfflineTilePyramidRegionDefinition definition) {
// update map
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
// correct style
mapboxMap.setStyle(definition.getStyleURL());
// position map on top of offline region
CameraPosition cameraPosition = OfflineUtils.getCameraPosition(definition);
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
// restrict camera movement
mapboxMap.setMinZoomPreference(definition.getMinZoom());
mapboxMap.setMaxZoomPreference(definition.getMaxZoom());
mapboxMap.setLatLngBoundsForCameraTarget(definition.getBounds());
}
});
// update textview data
nameView.setText(OfflineUtils.convertRegionName(offlineRegion.getMetadata()));
styleView.setText(definition.getStyleURL());
latLngBoundsView.setText(definition.getBounds().toString());
minZoomView.setText(String.valueOf(definition.getMinZoom()));
maxZoomView.setText(String.valueOf(definition.getMaxZoom()));
offlineRegion.getStatus(offlineRegionStatusCallback);
}
use of com.mapbox.mapboxsdk.camera.CameraPosition in project mapbox-plugins-android by mapbox.
the class ClusterManagerPlugin method onCameraIdle.
/**
* Might re-cluster.
*/
@Override
public void onCameraIdle() {
Timber.d("OnCamerIdle");
if (mRenderer instanceof MapboxMap.OnCameraIdleListener) {
((MapboxMap.OnCameraIdleListener) mRenderer).onCameraIdle();
}
// Don't re-compute clusters if the map has just been panned/tilted/rotated.
CameraPosition position = mMap.getCameraPosition();
if (mPreviousCameraPosition != null && mPreviousCameraPosition.zoom == position.zoom) {
return;
}
mPreviousCameraPosition = mMap.getCameraPosition();
Timber.e("OnCluster");
cluster();
}
Aggregations