Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 229612

Postal_code in Ionic Framework?

$
0
0

Hi, @arunaraj

Add ionic Native Geocoder plugin in your app for get postal_code,

ionic cordova plugin add cordova-plugin-nativegeocoder

npm install --save @ionic-native/native-geocoder

Now, add this plugin in app.module file,

import { NativeGeocoder } from '@ionic-native/native-geocoder';

@NgModule({
    ......
    providers: [
        NativeGeocoder
    ]
    ......
})
export class AppModule {}

Now, you add this code in component file,

import { NativeGeocoder, NativeGeocoderReverseResult, NativeGeocoderForwardResult } from '@ionic-native/native-geocoder';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
     constructor(private nativeGeocoder: NativeGeocoder) { }

     getPostalCode(){
          this.nativeGeocoder.reverseGeocode(<latitude>, <longitude>)
         .then((result: NativeGeocoderReverseResult) => console.log(JSON.stringify(result)))
         .catch((error: any) => console.log(error));
     }
}

Thanks.


Viewing all articles
Browse latest Browse all 229612

Trending Articles



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