nitaliano / react-native-mapbox-gl

A Mapbox GL react native module for creating custom maps
Other
2.16k stars 697 forks source link

showUserLocation not working on Android #1479

Open EffectusSanti opened 5 years ago

EffectusSanti commented 5 years ago

The map is working fine on iOS, but I can't see the user location on Android (zoom and coords aren't working well either).

I followed the installation instructions and have the FINE_LOCATION and other permissions granted.

The only thing I changed was in my build.gradle, to prevent the app from crashing:

compile (project(':mapbox-react-native-mapbox-gl')) {
        compile ('com.squareup.okhttp3:okhttp:3.6.0') {
            force = true
        }
}
ghost commented 5 years ago

I'm having the same issue

kgelpes commented 5 years ago

I'm also having this problem

nitaliano commented 5 years ago

what location engine are you using?

nicoceledon commented 5 years ago

Same here on Android, but working well on iOS emulator.

alexiri commented 5 years ago

what location engine are you using?

I have this issue as well, adding the parameter userTrackingMode makes the map break.

nicoceledon commented 5 years ago

Doing some testing, i still haven't figure this out completely but i tried requesting permissions like this and it worked (reference link)

import { PermissionsAndroid } from 'react-native';
...
componentDidMount() {
{
 PermissionsAndroid.requestMultiple(
            [PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
            PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION],
            {
                title: 'Give Location Permission',
            message: 'App needs location permission to find your position.'
        }
    ).then(granted => {
        console.log(granted);
        resolve();
    }).catch(err => {
        console.warn(err);
        reject(err);
    });
}

And i was able to pickup the location and zoom in. I'm still having troubles though. I have to restart the app to show the location. I guess it has to do with where i'm requesting the permissions. I don't have the permissions in the AndroidManifest.xml.

Android: 8.0 react-native: 0.56.0 react-native-mapbox-gl: 6.1.3

tahir-jamil commented 4 years ago

still not working for me