Search in sources :

Example 1 with LocationLayerPlugin

use of com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin 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 LocationLayerPlugin

use of com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin in project mapbox-navigation-android by mapbox.

the class MockNavigationActivity method onMapReady.

@Override
public void onMapReady(MapboxMap mapboxMap) {
    this.mapboxMap = mapboxMap;
    locationLayerPlugin = new LocationLayerPlugin(mapView, mapboxMap, null);
    locationLayerPlugin.setLocationLayerEnabled(LocationLayerMode.NAVIGATION);
    navigationMapRoute = new NavigationMapRoute(navigation, mapView, mapboxMap);
    mapboxMap.addOnMapClickListener(this);
    Snackbar.make(mapView, "Tap map to place waypoint", BaseTransientBottomBar.LENGTH_LONG).show();
    locationEngine = new MockLocationEngine(1000, 50, true);
    mapboxMap.setLocationSource(locationEngine);
    newOrigin();
}
Also used : LocationLayerPlugin(com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin) NavigationMapRoute(com.mapbox.services.android.navigation.ui.v5.route.NavigationMapRoute) MockLocationEngine(com.mapbox.services.android.navigation.v5.location.MockLocationEngine)

Example 3 with LocationLayerPlugin

use of com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin in project mapbox-navigation-android by mapbox.

the class NavigationViewActivity method initLocationLayer.

@SuppressWarnings({ "MissingPermission" })
private void initLocationLayer() {
    locationLayer = new LocationLayerPlugin(mapView, mapboxMap, locationEngine);
    locationLayer.setLocationLayerEnabled(LocationLayerMode.COMPASS);
}
Also used : LocationLayerPlugin(com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin)

Example 4 with LocationLayerPlugin

use of com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin in project mapbox-navigation-android by mapbox.

the class NavigationView method initLocationLayer.

/**
 * Initializes the {@link LocationLayerPlugin} to be used to draw the current
 * location.
 */
@SuppressWarnings({ "MissingPermission" })
private void initLocationLayer() {
    int locationLayerStyleRes = ThemeSwitcher.retrieveNavigationViewStyle(getContext(), R.attr.navigationViewLocationLayerStyle);
    locationLayer = new LocationLayerPlugin(mapView, map, null, locationLayerStyleRes);
    locationLayer.setLocationLayerEnabled(LocationLayerMode.NAVIGATION);
}
Also used : LocationLayerPlugin(com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin) Point(com.mapbox.geojson.Point)

Example 5 with LocationLayerPlugin

use of com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin 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)

Aggregations

LocationLayerPlugin (com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin)8 LocationEngineProvider (com.mapbox.android.core.location.LocationEngineProvider)4 SuppressLint (android.annotation.SuppressLint)2 MockLocationEngine (com.mapbox.services.android.navigation.v5.location.MockLocationEngine)2 LocationEngine (com.mapbox.android.core.location.LocationEngine)1 Point (com.mapbox.geojson.Point)1 CameraPosition (com.mapbox.mapboxsdk.camera.CameraPosition)1 CompassListener (com.mapbox.mapboxsdk.plugins.locationlayer.CompassListener)1 LocationLayerOptions (com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerOptions)1 NavigationMapRoute (com.mapbox.services.android.navigation.ui.v5.route.NavigationMapRoute)1