Search in sources :

Example 6 with CameraPosition

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);
    }
}
Also used : CameraPosition(com.mapbox.mapboxsdk.camera.CameraPosition) LatLng(com.mapbox.mapboxsdk.geometry.LatLng)

Example 7 with CameraPosition

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);
}
Also used : CameraPosition(com.mapbox.mapboxsdk.camera.CameraPosition) Parcel(android.os.Parcel) Intent(android.content.Intent) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 8 with CameraPosition

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);
        }
    });
}
Also used : LocationEngine(com.mapbox.android.core.location.LocationEngine) LocationLayerPlugin(com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin) CameraPosition(com.mapbox.mapboxsdk.camera.CameraPosition) CompassListener(com.mapbox.mapboxsdk.plugins.locationlayer.CompassListener) LocationEngineProvider(com.mapbox.android.core.location.LocationEngineProvider)

Example 9 with CameraPosition

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);
}
Also used : CameraPosition(com.mapbox.mapboxsdk.camera.CameraPosition) OnMapReadyCallback(com.mapbox.mapboxsdk.maps.OnMapReadyCallback) MapboxMap(com.mapbox.mapboxsdk.maps.MapboxMap)

Example 10 with CameraPosition

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();
}
Also used : CameraPosition(com.mapbox.mapboxsdk.camera.CameraPosition)

Aggregations

CameraPosition (com.mapbox.mapboxsdk.camera.CameraPosition)19 LatLng (com.mapbox.mapboxsdk.geometry.LatLng)8 MapboxMap (com.mapbox.mapboxsdk.maps.MapboxMap)4 AnimatorSet (android.animation.AnimatorSet)3 Point (com.mapbox.geojson.Point)3 CameraUpdate (com.mapbox.mapboxsdk.camera.CameraUpdate)3 LatLngBounds (com.mapbox.mapboxsdk.geometry.LatLngBounds)3 Camera (com.mapbox.services.android.navigation.v5.navigation.camera.Camera)2 ValueAnimator (android.animation.ValueAnimator)1 Intent (android.content.Intent)1 Handler (android.os.Handler)1 Parcel (android.os.Parcel)1 MotionEvent (android.view.MotionEvent)1 ScaleGestureDetector (android.view.ScaleGestureDetector)1 View (android.view.View)1 LocationEngine (com.mapbox.android.core.location.LocationEngine)1 LocationEngineProvider (com.mapbox.android.core.location.LocationEngineProvider)1 LegStep (com.mapbox.api.directions.v5.models.LegStep)1 Marker (com.mapbox.mapboxsdk.annotations.Marker)1 MapView (com.mapbox.mapboxsdk.maps.MapView)1