Search in sources :

Example 1 with LocationComponent

use of com.mapbox.mapboxsdk.location.LocationComponent in project apps-android-wikipedia by wikimedia.

the class NearbyFragment method enableUserLocationMarker.

@SuppressWarnings("MissingPermission")
private void enableUserLocationMarker() {
    if (mapboxMap != null && locationPermitted()) {
        LocationComponentOptions options = LocationComponentOptions.builder(requireActivity()).trackingGesturesManagement(true).build();
        LocationComponent locationComponent = mapboxMap.getLocationComponent();
        locationComponent.activateLocationComponent(requireActivity(), mapboxMap.getStyle(), options);
        locationComponent.setLocationComponentEnabled(true);
        locationComponent.setCameraMode(CameraMode.TRACKING);
        locationComponent.setRenderMode(RenderMode.COMPASS);
    }
}
Also used : LocationComponentOptions(com.mapbox.mapboxsdk.location.LocationComponentOptions) LocationComponent(com.mapbox.mapboxsdk.location.LocationComponent)

Example 2 with LocationComponent

use of com.mapbox.mapboxsdk.location.LocationComponent in project apps-android-commons by commons-app.

the class LocationPickerActivity method enableLocationComponent.

/**
 * Enables location components
 * @param loadedMapStyle Style
 */
@SuppressWarnings({ "MissingPermission" })
private void enableLocationComponent(@NonNull final Style loadedMapStyle) {
    final UiSettings uiSettings = mapboxMap.getUiSettings();
    uiSettings.setAttributionEnabled(false);
    // Check if permissions are enabled and if not request
    if (PermissionsManager.areLocationPermissionsGranted(this)) {
        // Get an instance of the component
        final LocationComponent locationComponent = mapboxMap.getLocationComponent();
        // Activate with options
        locationComponent.activateLocationComponent(LocationComponentActivationOptions.builder(this, loadedMapStyle).build());
        // Enable to make component visible
        locationComponent.setLocationComponentEnabled(true);
        // Set the component's camera mode
        locationComponent.setCameraMode(CameraMode.NONE);
        // Set the component's render mode
        locationComponent.setRenderMode(RenderMode.NORMAL);
    }
}
Also used : UiSettings(com.mapbox.mapboxsdk.maps.UiSettings) LocationComponent(com.mapbox.mapboxsdk.location.LocationComponent)

Example 3 with LocationComponent

use of com.mapbox.mapboxsdk.location.LocationComponent in project mapbox-plugins-android by mapbox.

the class PlacePickerActivity method enableLocationComponent.

@SuppressWarnings({ "MissingPermission" })
private void enableLocationComponent(@NonNull Style loadedMapStyle) {
    // Check if permissions are enabled and if not request
    if (PermissionsManager.areLocationPermissionsGranted(this)) {
        // Get an instance of the component
        LocationComponent locationComponent = mapboxMap.getLocationComponent();
        // Activate with options
        locationComponent.activateLocationComponent(LocationComponentActivationOptions.builder(this, loadedMapStyle).build());
        // Enable to make component visible
        locationComponent.setLocationComponentEnabled(true);
        // Set the component's camera mode
        locationComponent.setCameraMode(CameraMode.NONE);
        // Set the component's render mode
        locationComponent.setRenderMode(RenderMode.NORMAL);
        addUserLocationButton();
    } else {
        permissionsManager = new PermissionsManager(this);
        permissionsManager.requestLocationPermissions(this);
    }
}
Also used : PermissionsManager(com.mapbox.android.core.permissions.PermissionsManager) LocationComponent(com.mapbox.mapboxsdk.location.LocationComponent)

Aggregations

LocationComponent (com.mapbox.mapboxsdk.location.LocationComponent)3 PermissionsManager (com.mapbox.android.core.permissions.PermissionsManager)1 LocationComponentOptions (com.mapbox.mapboxsdk.location.LocationComponentOptions)1 UiSettings (com.mapbox.mapboxsdk.maps.UiSettings)1