How can I get the postal code with the native plugin GoogleMaps for ionic?
Thx
How can I get the postal code with the native plugin GoogleMaps for ionic?
Thx
You can get it with GeocoderRequest. See the docs:
Yes, I dont know how make the code. Maybe this:
doGeocode(marker) {
let request: GeocoderRequest = {
position: new LatLng(this.myPosition.latitude, this.myPosition.longitude),
};
this.geocoder.geocode(request)
.then((res) => {
//https://ionicframework.com/docs/native/google-maps/#GeocoderResult
let results = res as GeocoderResult
let address = [
(results[0].thoroughfare || "") + " " + (results[0].subThoroughfare || ""),
results[0].locality
].join(", ");
console.log("data_: ", address);
marker.setTitle(address);
marker.showInfoWindow();
});
}