Skip to content

"My location" not shown on map #451

@sreekanth-krishnan

Description

@sreekanth-krishnan

I'm trying to use location layer to show user location in the map because 'setMyLocationEnabled' is deprecated.

Below is my code


    @SuppressWarnings( {"MissingPermission"})
    private void enableLocationPlugin() {
        // Check if permissions are enabled and if not request
        if (PermissionsManager.areLocationPermissionsGranted(getContext())) {
            // Create a location engine instance
            initializeLocationEngine();

            locationPlugin = new LocationLayerPlugin(((MapView)mapFragment.getView()), mGoogleMap, locationEngine);
            locationPlugin.setLocationLayerEnabled(true);
        }/* else {
            permissionsManager = new PermissionsManager(this);
            permissionsManager.requestLocationPermissions(this);
        }*/
    }

    @SuppressWarnings( {"MissingPermission"})
    private void initializeLocationEngine() {
        locationEngine = new LocationEngineProvider(getContext()).obtainBestLocationEngineAvailable();
        locationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY);
        locationEngine.activate();
/*
        Location lastLocation = locationEngine.getLastLocation();
        if (lastLocation != null) {
            setCameraPosition(lastLocation);
        } else {
            locationEngine.addLocationEngineListener(this);
        }*/
    }

I call enableLocationPlugin from onMapReady after checking/requesting permissions.
I'm using SupportMapFragment.

I saw the demo app has some issues and shows the location only after navigating away from the app and returning back to it. But even that's not working in my implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions