2016-09-14 2 views
0

나는 '반응 - 네이티브 지오 코더를'나는 내 응용 프로그램에서이 코드 조각을 사용했다 라이브러리 사용하고 있습니다 : 오류Geocoder.geocodePosition 정의되지 않은 함수 오류

//reverse - geocoding 
var NY = { 
     lat: 40.7809261, 
     lng: -73.9637594 
    }; 

Geocoder.geocodePosition(NY).then(res => { 
    // res is an Array of geocoding object (see below) 
    //location details goes here 
}) 
.catch(err => console.log(err)) 

을하지만 점점 :

geocodePostion is undefined function

저는 "react-native": "0.31.0", "react-native-geocoder": "^0.4.5"을 사용 중이며 라이브러리에 언급 된 구성 단계를 수행했습니다.

+0

위치를 얻으려면 'Geolocation' https://facebook.github.io/react-native/docs/geolocation.html을 사용하지 않는 이유는 무엇입니까? –

+0

오류 메시지에서 geocodePosition의 i가 누락되었습니다. 그러나 코드에는 코드가 있습니다. – lucash

답변

2

내가이 code.I에 의해 고정되었다 위도와 경도의 위치 표시를 얻으려고 노력했다

var myAddress = '' 

      var NY = { 
        lat: this.state.position.coords.latitude, 
        lng: this.state.position.coords.longitude 
        }; 

Geocoder.fallbackToGoogle(MY_KEY);//MY_KEY -- enabled the key googleMapAPI portal. 
// use the lib as usual 
let ret = Geocoder.geocodePosition(NY).then((res)=> 
{ 
    console.log(res) 
    myAddress = res["0"].formattedAddress 
    console.log(myAddress); 
    this.setState({ 
      MyAddress: myAddress 
     }); 
}) 
console.log(this.state.MyAddress); 

나는 "반응 네이티브"사용하고 있습니다 : "0.31.0를", "react- native-geocoder ":"^ 0.4.5 "및 라이브러리에 언급 된 구성 단계를 수행했습니다.

관련 문제