Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70440

Native Geocoder

$
0
0

@flycoders_sourav wrote:

Native geocoder is not working properly
below my code

this.geolocation.getCurrentPosition().then((resp) => {
      // resp.coords.latitude
      // resp.coords.longitude
      console.log(resp.coords.latitude);
      console.log(resp.coords.longitude);


      let options: NativeGeocoderOptions = {
        useLocale: true,
        maxResults: 5
    };
    
    this.nativeGeocoder.reverseGeocode(resp.coords.latitude,resp.coords.longitude)
      .then((result: NativeGeocoderReverseResult[]) => alert(JSON.stringify(result[0])))
      .catch((error: any) => alert("error"+error));
    
    this.nativeGeocoder.forwardGeocode('Berlin', options)
      .then((coordinates: NativeGeocoderForwardResult[]) =>alert('The coordinates are latitude=' + coordinates[0].latitude + ' and longitude=' + coordinates[0].longitude))
      .catch((error: any) => alert("error"+error));


     }).catch((error) => {
       console.log('Error getting location', error);
     });
     
     let watch = this.geolocation.watchPosition();
     watch.subscribe((data) => {
      // data can be a set of coordinates, or an error (if an error occurred).
      // data.coords.latitude
      // data.coords.longitude
     });

Please anyone suggest me what I’m wrong.
Thanks

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70440

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>