相关疑难解决方法(0)

使用React Native和iOS模拟器进行错误的地理定位

我正在使用react-native-maps并使用react-native api进行地理定位.当我通过api使用位置时,在模拟器上返回的信息显示我在旧金山不在我所在的丹佛科罗拉多州.有没有理由为什么我的位置不会显示我在哪里?

我运行该位置的功能

  // Get current users locaiton on load
  componentDidMount() {
    navigator.geolocation.getCurrentPosition((position) => {
      console.log(position);
      let newLat = parseFloat(position.coords.latitude);
      console.log("newLat", newLat);
      let newLng = parseFloat(position.coords.longitude);
      console.log("newLng", newLng);
      // set region of user to lat and long position
      // deltas set distance from marker (zoom) on map
      this.setState({
        region: {
          latitude: newLat,
          longitude: newLng,
          latitudeDelta: 0.0250,
          longitudeDelta: 0.0125
        },
        error: null
      });
      console.log(this.state);
    }, 
      // if error set state with error
      (err) => {
        console.log(err),
        // set location accuracy on …
Run Code Online (Sandbox Code Playgroud)

ios ios-simulator apple-maps react-native react-native-maps

3
推荐指数
1
解决办法
4176
查看次数

地理定位在iOS 8模拟器中不起作用

我已经升级了cordova 3.5中的geolocation插件,通过以下帖子解决了iOS 8中的问题.

http://shazronatadobe.wordpress.com/2014/09/18/cordova-ios-and-ios-8/

在iOS8模拟器中运行应用程序后,我收到通知"允许"MyApp"在您使用应用程序时访问您的位置?" 但locationManager::didFailWithError在允许位置服务使用应用程序后,它仍然显示错误(null).我试图关闭模拟器并一次又一次地运行它.此外,通过检查模拟器中的设置,似乎位置服务处于活动状态(设置>隐私>位置服务> MyApp>使用时).通过在iOS 7中运行相同的应用程序,模拟器工作正常并且能够检测到lat/lng.

仅供参考:我使用Xcode 6来构建应用程序.

任何帮助/建议都会有所帮助.

geolocation ios cordova xcode6 ios8

2
推荐指数
1
解决办法
4510
查看次数