Search code examples
react-nativereact-native-iosreact-native-mapslocation-services

React Native Maps - showsUserLocation not working


I'm using React Native Maps to show a map on ios/Android.

I'm yet to give it a proper test on Android but on ios I can't get the showsUserLocation prop to actually show the location dot.

I've followed the docs and made sure I added NSLocationAlwaysAndWhenInUseUsageDescription with a description in the Info.plist file.

My Info.plist file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    ...
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>We need to access your location to provide location specific points to visit</string>
    ...
</dict>

and my MapView is initialised like so:

<MapView
    provider={PROVIDER_GOOGLE}
    style={styles.map}
    initialRegion={initial}
    mapType={mapType}
    onRegionChange={handleRegionChange}
    onMapReady={() => setRegionReady(true)}
    showsUserLocation={true} // here is what I thought should show it
    showsMyLocationButton={true}
>
    ... // markers rendered here
</MapView>

No location dot though. When the app loads it asks for permission to view location which I've granted and I've also checked in settings and it should have location access "when in use"

I've also tried setting the "Simulate Location" options in Xcode to London, United Kingdom but it still doesn't show.

Is there anything I'm missing?

enter image description here


Solution

  • You need to set your location in the simulator > Features > Location > Custom Location settings to be able to see your location marked on the map.