创新互联React教程:定位
你需要在 info.plist 中添加 NSLocationWhenInUseUsageDescription 键来定位,当你用 react-native init 来创建一个项目时,默认情况下定位是能够使用的。

创新互联主要从事做网站、网站制作、网页设计、企业做网站、公司建网站等业务。立足成都服务东至,十年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:028-86922220
定位遵循 MDN 规范:
https://developer.mozilla.org/en-US/docs/Web/API/Geolocation
方法
static getCurrentPosition(geo_success: Function, geo_error?: Function, geo_options?: Object)
static watchPosition(success: Function, error?: Function, options?: Object)
static clearWatch(watchID: number)
static stopObserving()
例子
Edit on GitHub
/* eslint no-console: 0 */'use strict';var React = require('react-native');var {
  StyleSheet,
  Text,
  View,
} = React;
exports.framework = 'React';
exports.title = 'Geolocation';
exports.description = 'Examples of using the Geolocation API.';
exports.examples = [
  {
    title: 'navigator.geolocation',
    render: function(): ReactElement {      return 
        
          Initial position:  
          {JSON.stringify(this.state.initialPosition)}         
        
          Current position:  
          {JSON.stringify(this.state.lastPosition)}         
       
    );
  }
});var styles = StyleSheet.create({
  title: {
    fontWeight: '500',
  },
});
文章名称:创新互联React教程:定位
文章URL:http://jxruijie.cn/article/dhpsppg.html

 
                