日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)React教程:定位

你需要在 info.plist 中添加 NSLocationWhenInUseUsageDescription 鍵來定位,當(dāng)你用 react-native init 來創(chuàng)建一個項目時,默認(rèn)情況下定位是能夠使用的。

創(chuàng)新互聯(lián)主要從事做網(wǎng)站、網(wǎng)站制作、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)東至,十年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):028-86922220

定位遵循 MDN 規(guī)范:
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 ;
    },
  }
];var GeolocationExample = React.createClass({
  watchID: (null: ?number),
  getInitialState: function() {    return {
      initialPosition: 'unknown',
      lastPosition: 'unknown',
    };
  },
  componentDidMount: function() {
    navigator.geolocation.getCurrentPosition(
      (initialPosition) => this.setState({initialPosition}),
      (error) => console.error(error)
    );    this.watchID = navigator.geolocation.watchPosition((lastPosition) => {      this.setState({lastPosition});
    });
  },
  componentWillUnmount: function() {
    navigator.geolocation.clearWatch(this.watchID);
  },
  render: function() {    return (      
        
          Initial position: 
          {JSON.stringify(this.state.initialPosition)}        
        
          Current position: 
          {JSON.stringify(this.state.lastPosition)}        
      
    );
  }
});var styles = StyleSheet.create({
  title: {
    fontWeight: '500',
  },
});


網(wǎng)頁題目:創(chuàng)新互聯(lián)React教程:定位
標(biāo)題URL:http://www.dlmjj.cn/article/dhpsppg.html