Wrong Geolocation with React Native and iOS simulator

后端 未结 1 678
囚心锁ツ
囚心锁ツ 2021-01-14 15:37

I am working with react-native-maps and using the react-native api for geolocation. When I am using location through the api what comes back on the simulator shows me in San

相关标签:
1条回答
  • 2021-01-14 15:39

    That is the correct behavior on the iOS simulator (and the Android emulator). You can change the mocked coordinates for geolocation on each like so (paraphrased from other answers):

    iOS

    1. Run app in iOS simulator.
    2. At the top menu bar, you'll find Features -> Location -> Custom Location..(or you can choose to use others).
    3. Set the Latitude & Longitude for the location.

    Android

    1. Run app in Android emulator.
    2. Click on the ellipsis (...) in the toolbar.
    3. Edit the coordinates in the newly opened settings under Location.

    There's also a command line alternative for Android explained here using telnet and the geo fix command.

    Or, you can do as ashutosh pandey suggests and test on a real device.

    0 讨论(0)
提交回复
热议问题