Search in sources :

Example 1 with LocationEngineProvider

use of com.mapbox.android.core.location.LocationEngineProvider in project mapbox-plugins-android by mapbox.

the class ManualLocationUpdatesActivity method onMapReady.

@Override
@SuppressWarnings({ "MissingPermission" })
public void onMapReady(MapboxMap mapboxMap) {
    this.mapboxMap = mapboxMap;
    locationEngine = new LocationEngineProvider(this).obtainBestLocationEngineAvailable();
    locationEngine.addLocationEngineListener(this);
    locationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY);
    locationEngine.activate();
    locationLayerPlugin = new LocationLayerPlugin(mapView, mapboxMap, null);
    locationLayerPlugin.setRenderMode(RenderMode.NORMAL);
    getLifecycle().addObserver(locationLayerPlugin);
}
Also used : LocationLayerPlugin(com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin) LocationEngineProvider(com.mapbox.android.core.location.LocationEngineProvider)

Example 2 with LocationEngineProvider

use of com.mapbox.android.core.location.LocationEngineProvider 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 3 with LocationEngineProvider

use of com.mapbox.android.core.location.LocationEngineProvider in project mapbox-plugins-android by mapbox.

the class LocationLayerMapChangeActivity method onMapReady.

@Override
public void onMapReady(MapboxMap mapboxMap) {
    this.mapboxMap = mapboxMap;
    locationEngine = new LocationEngineProvider(this).obtainBestLocationEngineAvailable();
    locationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY);
    locationEngine.activate();
    locationPlugin = new LocationLayerPlugin(mapView, mapboxMap, locationEngine);
    locationPlugin.setRenderMode(RenderMode.COMPASS);
    getLifecycle().addObserver(locationPlugin);
}
Also used : LocationLayerPlugin(com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin) LocationEngineProvider(com.mapbox.android.core.location.LocationEngineProvider)

Example 4 with LocationEngineProvider

use of com.mapbox.android.core.location.LocationEngineProvider in project mapbox-plugins-android by mapbox.

the class LocationLayerModesActivity method onMapReady.

@SuppressLint("MissingPermission")
@Override
public void onMapReady(MapboxMap mapboxMap) {
    this.mapboxMap = mapboxMap;
    locationEngine = new LocationEngineProvider(this).obtainBestLocationEngineAvailable();
    locationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY);
    locationEngine.setFastestInterval(1000);
    locationEngine.addLocationEngineListener(this);
    locationEngine.activate();
    int[] padding;
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        padding = new int[] { 0, 750, 0, 0 };
    } else {
        padding = new int[] { 0, 250, 0, 0 };
    }
    LocationLayerOptions options = LocationLayerOptions.builder(this).padding(padding).build();
    locationLayerPlugin = new LocationLayerPlugin(mapView, mapboxMap, locationEngine, options);
    locationLayerPlugin.addOnLocationClickListener(this);
    locationLayerPlugin.addOnCameraTrackingChangedListener(this);
    locationLayerPlugin.setCameraMode(cameraMode);
    setRendererMode(renderMode);
    getLifecycle().addObserver(locationLayerPlugin);
}
Also used : LocationLayerOptions(com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerOptions) LocationLayerPlugin(com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin) LocationEngineProvider(com.mapbox.android.core.location.LocationEngineProvider) SuppressLint(android.annotation.SuppressLint)

Aggregations

LocationEngineProvider (com.mapbox.android.core.location.LocationEngineProvider)4 LocationLayerPlugin (com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin)4 SuppressLint (android.annotation.SuppressLint)1 LocationEngine (com.mapbox.android.core.location.LocationEngine)1 CameraPosition (com.mapbox.mapboxsdk.camera.CameraPosition)1 CompassListener (com.mapbox.mapboxsdk.plugins.locationlayer.CompassListener)1 LocationLayerOptions (com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerOptions)1