Siga a localization do user no MapView do React Native AirBnb

Estou usando o mapa do airbnb paira reagir nativo no meu aplicativo. Esta questão é paira o aplicativo Android desde que eu não findi o aplicativo iOS ainda.

Meu problema:

  • Usando o sensor de orientação paira apontair paira um local específico
  • O aplicativo Phonegap morre em segundo plano ao colecionair local
  • A geolocation do phonegap sempre crash no timeout
  • Não é possível obter coordenadas GPS usando o Javascript no browser no Android
  • Localizair localization usando MCC, MNC, LAC e Cell ID
  • J2ME / Android / BlackBerry - direções de direção, rota entre dois locais
  • navigator.geolocation funciona bem no emulador, mas leva muito tempo em dispositivos reais, até o ponto às vezes expira em dispositivos antigos.

    O que eu notei:

    se showsUserLocation prop for definido como true, eu posso view o maircador nativo da "position atual" no mapa antes que getCurrentPosition se resolva.

    O que eu quero:

    1. Quero que minha região sempre seja cinput na localization do user.
    2. Quero uma maneira de acessair a localization nativa de localization geográfica (deve ser mais rápido?), Ou talvez alguém me diga o que estou fazendo de errado. Abaixo está um exemplo de código.
    3. Eu ainda posso detectair a localization do user mesmo depois que os services de localization foram ativados / desativados. Este é o comportamento do showsUserLocation , mas pairece que os erros ViewPostion, pára completamente.

    Aqui está o que eu tenho até agora, é muito simples como é:

      componentDidMount() { navigator.geolocation.getCurrentPosition( (position) => { console.log("getCurrentPosition Success"); this.setState({ region: { ...this.state.region, latitude: position.coords.latitude, longitude: position.coords.longitude, } }); this.props.resetNotifications(); this.watchPosition(); }, (error) => { this.props.displayError("Error dectecting your location"); alert(JSON.stringify(error)) }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } watchPosition() { this.watchID = navigator.geolocation.watchPosition( (position) => { console.log("watchPosition Success"); if(this.props.followUser){ this.map.animateToRegion(this.newRegion(position.coords.latitude, position.coords.longitude)); } }, (error) => { this.props.displayError("Error dectecting your location"); }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } }  componentDidMount() { navigator.geolocation.getCurrentPosition( (position) => { console.log("getCurrentPosition Success"); this.setState({ region: { ...this.state.region, latitude: position.coords.latitude, longitude: position.coords.longitude, } }); this.props.resetNotifications(); this.watchPosition(); }, (error) => { this.props.displayError("Error dectecting your location"); alert(JSON.stringify(error)) }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } watchPosition() { this.watchID = navigator.geolocation.watchPosition( (position) => { console.log("watchPosition Success"); if(this.props.followUser){ this.map.animateToRegion(this.newRegion(position.coords.latitude, position.coords.longitude)); } }, (error) => { this.props.displayError("Error dectecting your location"); }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } });  componentDidMount() { navigator.geolocation.getCurrentPosition( (position) => { console.log("getCurrentPosition Success"); this.setState({ region: { ...this.state.region, latitude: position.coords.latitude, longitude: position.coords.longitude, } }); this.props.resetNotifications(); this.watchPosition(); }, (error) => { this.props.displayError("Error dectecting your location"); alert(JSON.stringify(error)) }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } watchPosition() { this.watchID = navigator.geolocation.watchPosition( (position) => { console.log("watchPosition Success"); if(this.props.followUser){ this.map.animateToRegion(this.newRegion(position.coords.latitude, position.coords.longitude)); } }, (error) => { this.props.displayError("Error dectecting your location"); }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } },  componentDidMount() { navigator.geolocation.getCurrentPosition( (position) => { console.log("getCurrentPosition Success"); this.setState({ region: { ...this.state.region, latitude: position.coords.latitude, longitude: position.coords.longitude, } }); this.props.resetNotifications(); this.watchPosition(); }, (error) => { this.props.displayError("Error dectecting your location"); alert(JSON.stringify(error)) }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } watchPosition() { this.watchID = navigator.geolocation.watchPosition( (position) => { console.log("watchPosition Success"); if(this.props.followUser){ this.map.animateToRegion(this.newRegion(position.coords.latitude, position.coords.longitude)); } }, (error) => { this.props.displayError("Error dectecting your location"); }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } },  componentDidMount() { navigator.geolocation.getCurrentPosition( (position) => { console.log("getCurrentPosition Success"); this.setState({ region: { ...this.state.region, latitude: position.coords.latitude, longitude: position.coords.longitude, } }); this.props.resetNotifications(); this.watchPosition(); }, (error) => { this.props.displayError("Error dectecting your location"); alert(JSON.stringify(error)) }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } watchPosition() { this.watchID = navigator.geolocation.watchPosition( (position) => { console.log("watchPosition Success"); if(this.props.followUser){ this.map.animateToRegion(this.newRegion(position.coords.latitude, position.coords.longitude)); } }, (error) => { this.props.displayError("Error dectecting your location"); }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } );  componentDidMount() { navigator.geolocation.getCurrentPosition( (position) => { console.log("getCurrentPosition Success"); this.setState({ region: { ...this.state.region, latitude: position.coords.latitude, longitude: position.coords.longitude, } }); this.props.resetNotifications(); this.watchPosition(); }, (error) => { this.props.displayError("Error dectecting your location"); alert(JSON.stringify(error)) }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } watchPosition() { this.watchID = navigator.geolocation.watchPosition( (position) => { console.log("watchPosition Success"); if(this.props.followUser){ this.map.animateToRegion(this.newRegion(position.coords.latitude, position.coords.longitude)); } }, (error) => { this.props.displayError("Error dectecting your location"); }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } }  componentDidMount() { navigator.geolocation.getCurrentPosition( (position) => { console.log("getCurrentPosition Success"); this.setState({ region: { ...this.state.region, latitude: position.coords.latitude, longitude: position.coords.longitude, } }); this.props.resetNotifications(); this.watchPosition(); }, (error) => { this.props.displayError("Error dectecting your location"); alert(JSON.stringify(error)) }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } watchPosition() { this.watchID = navigator.geolocation.watchPosition( (position) => { console.log("watchPosition Success"); if(this.props.followUser){ this.map.animateToRegion(this.newRegion(position.coords.latitude, position.coords.longitude)); } }, (error) => { this.props.displayError("Error dectecting your location"); }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } }  componentDidMount() { navigator.geolocation.getCurrentPosition( (position) => { console.log("getCurrentPosition Success"); this.setState({ region: { ...this.state.region, latitude: position.coords.latitude, longitude: position.coords.longitude, } }); this.props.resetNotifications(); this.watchPosition(); }, (error) => { this.props.displayError("Error dectecting your location"); alert(JSON.stringify(error)) }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } watchPosition() { this.watchID = navigator.geolocation.watchPosition( (position) => { console.log("watchPosition Success"); if(this.props.followUser){ this.map.animateToRegion(this.newRegion(position.coords.latitude, position.coords.longitude)); } }, (error) => { this.props.displayError("Error dectecting your location"); }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } },  componentDidMount() { navigator.geolocation.getCurrentPosition( (position) => { console.log("getCurrentPosition Success"); this.setState({ region: { ...this.state.region, latitude: position.coords.latitude, longitude: position.coords.longitude, } }); this.props.resetNotifications(); this.watchPosition(); }, (error) => { this.props.displayError("Error dectecting your location"); alert(JSON.stringify(error)) }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } watchPosition() { this.watchID = navigator.geolocation.watchPosition( (position) => { console.log("watchPosition Success"); if(this.props.followUser){ this.map.animateToRegion(this.newRegion(position.coords.latitude, position.coords.longitude)); } }, (error) => { this.props.displayError("Error dectecting your location"); }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } },  componentDidMount() { navigator.geolocation.getCurrentPosition( (position) => { console.log("getCurrentPosition Success"); this.setState({ region: { ...this.state.region, latitude: position.coords.latitude, longitude: position.coords.longitude, } }); this.props.resetNotifications(); this.watchPosition(); }, (error) => { this.props.displayError("Error dectecting your location"); alert(JSON.stringify(error)) }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } watchPosition() { this.watchID = navigator.geolocation.watchPosition( (position) => { console.log("watchPosition Success"); if(this.props.followUser){ this.map.animateToRegion(this.newRegion(position.coords.latitude, position.coords.longitude)); } }, (error) => { this.props.displayError("Error dectecting your location"); }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } );  componentDidMount() { navigator.geolocation.getCurrentPosition( (position) => { console.log("getCurrentPosition Success"); this.setState({ region: { ...this.state.region, latitude: position.coords.latitude, longitude: position.coords.longitude, } }); this.props.resetNotifications(); this.watchPosition(); }, (error) => { this.props.displayError("Error dectecting your location"); alert(JSON.stringify(error)) }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } watchPosition() { this.watchID = navigator.geolocation.watchPosition( (position) => { console.log("watchPosition Success"); if(this.props.followUser){ this.map.animateToRegion(this.newRegion(position.coords.latitude, position.coords.longitude)); } }, (error) => { this.props.displayError("Error dectecting your location"); }, {enableHighAccuracy: true, timeout: 20000, maximumAge: 1000} ); } 

  • Mova um LatLng 5 metros paira outro LatLng
  • Não é possível obter coordenadas GPS usando o Javascript no browser no Android
  • Android Compass aponta paira minha localization em vez de norte
  • Cordova Geolocation plugin retornando object de position vazia no Android
  • OnLocationChanged callback nunca é chamado
  • A geolocation do phonegap sempre crash no timeout
  • 2 Solutions collect form web for “Siga a localization do user no MapView do React Native AirBnb”

    Eu sempre findi watchPosition entre browseres diferentes, uma coisa que funcionou paira mim antes é replace com getCurrentPosition dentro de um setInterval paira que ele obtenha a localization a cada poucos segundos, e se ele crashr uma vez que irá repetir o próximo range, ao contrário de watchPosition que pára de view se ocorre um erro.

    Geralmente, a geolocation do browser não é muito confiável, você pode viewificair esse tópico paira alguns problemas https://github.com/facebook/react-native/issues/7495

    Outra alternativa que definitivamente será mais rápida e talvez mais confiável seja usair a API nativa de localization geográfica. Verifique esta questão paira as bibliotecas que expõem a geolocation nativa paira reagir na geolocation do Android React-native nativo

    Não tenho certeza se isso resolviewá o problema, mas tente isso:

     navigator.geolocation.getCurrentPosition( (position) => { console.log("getCurrentPosition Success"); this.setState({ region: { ...this.state.region, latitude: position.coords.latitude, longitude: position.coords.longitude, } }, () => { this.props.resetNotifications(); this.watchPosition(); }); }, } navigator.geolocation.getCurrentPosition( (position) => { console.log("getCurrentPosition Success"); this.setState({ region: { ...this.state.region, latitude: position.coords.latitude, longitude: position.coords.longitude, } }, () => { this.props.resetNotifications(); this.watchPosition(); }); }, }); navigator.geolocation.getCurrentPosition( (position) => { console.log("getCurrentPosition Success"); this.setState({ region: { ...this.state.region, latitude: position.coords.latitude, longitude: position.coords.longitude, } }, () => { this.props.resetNotifications(); this.watchPosition(); }); }, 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.