I am using Angular Google Maps in my app, but I cannot use google.maps.places.PlaceResult
as a type for an important variable in my code.
I am implementing this code: (Scroll down to Add Location/Places Search bar)
I am doing a places search on the map, and I am getting this error:
In this code:
ngOnInit() {
// Load places autocomplete
this.maps.load().then(() => {
this.setCurrentLocation();
this.geoCoder = new google.maps.geoCoder;
let autocomplete = new google.maps.places.autocomplete(this.searchElementRef.nativeElement, {
types: ["address"]
});
autocomplete.addListener("place_changed", () => {
this.ngZone.run(() => {
// Get the place result
let place: google.maps.places.PlaceResult = autocomplete.getPlace();
// Verify result
if (place.geometry === undefined || place.geometry === null) {
return;
}
// Set latitude, longitude & zoom
this.userLat = place.geometry.location.lat();
this.userLng = place.geometry.location.lng();
this.zoom = 12;
});
});
});
}
I am just following the example, but it seems to not recognize google
. How do you fix this?
I expect to use the example in the link as it is, but I cannot.
Thanks in advance!
types
to, from the answer you linked me? @JensHabegger – Nobenpm install --save @types/googlemaps
first – Armindaarming