-
Notifications
You must be signed in to change notification settings - Fork 117
Closed
Labels
location-layer-pluginIssues that deal with the location layer moduleIssues that deal with the location layer module
Milestone
Description
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
Labels
location-layer-pluginIssues that deal with the location layer moduleIssues that deal with the location layer module