The following snippet creates an Ambiguous call expression error:
/// <reference path="typings/google.maps.d.ts" />
class GoogleMap {
private geocoder;
private latlng;
constructor() {
this.geocoder = new google.maps.Geocoder();
this.latlng = new google.maps.LatLng(51.165691, 10.451526000000058);
}
private setElements(): void {
this.geocoder.geocode({ 'address': "Berlin", 'latLng': this.latlng }, (results) => {
var infowindow = new google.maps.InfoWindow();
infowindow.setContent(results[0].formatted_address); // 'Ambiguous call expression - could not choose overload'
})
}
setContent(...)
has 2 overloads and the compiler cannot solve the correct type even though the type of formatted_address
is solved correctly as string. However it works when I set the type of the method parameter explicit:
var content: string = results[0].formatted_address;
infowindow.setContent(content);
Also a strange point: I figured that this workaround is not neccessary when I declare infoWindow
as class variable.
For me it looks like a bug, or do I miss something?