Skip to content

UserLocation Problems #511

@viciopoli01

Description

@viciopoli01

I'm trying to get the user location using LocationEngine on Android devices , but when I star the app the usser's marker is located in (0.0, 0.0) and never update it's location.
How is it possible?

screenshot_20180515-170336_li

I try to replicate the example https://www.mapbox.com/android-docs/plugins/overview/location-layer/

`
private void enableLocationPlugin() {

    // Check if permissions are enabled and if not request
    if (PermissionsManager.areLocationPermissionsGranted(this)) {

        // Create an instance of LOST location engine
        initializeLocationEngine();
        LocationLayerOptions options = LocationLayerOptions.builder(this)
                .build();
        locationLayerPlugin = new LocationLayerPlugin(mapView, mapboxMap, locationEngine, options);
        locationLayerPlugin.setRenderMode(RenderMode.COMPASS);
        locationLayerPlugin.setCameraMode(CameraMode.TRACKING);
        locationLayerPlugin.setLocationLayerEnabled(true);
    } else {
        permissionsManager = new PermissionsManager(this);
        permissionsManager.requestLocationPermissions(this);
    }
}


private void initializeLocationEngine() {
    locationEngine = new LocationEngineProvider(this).obtainBestLocationEngineAvailable();
    locationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY);
    locationEngine.setInterval(1000);
    locationEngine.setFastestInterval(500);
    locationEngine.addLocationEngineListener(this);
    locationEngine.activate();
    locationEngine.requestLocationUpdates();

    
    Location lastLocation = locationEngine.getLastLocation();
    if (lastLocation != null) {
        setCameraPosition(lastLocation);
        locationEngine.addLocationEngineListener(this);
    } else {
        locationEngine.addLocationEngineListener(this);
    }
}

`
I'm using this version of MapBox in grandle

implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-building:0.2.0' implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.12.0' implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.5.2'

Metadata

Metadata

Assignees

No one assigned

    Labels

    location-layer-pluginIssues that deal with the location layer module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions