return this.loadMap().then(() => {
const myLatLng = new google.maps.LatLng(opts.lat, opts.lon);
const styleArray = [
{
featureType: 'poi',
elementType: 'labels',
stylers: [
{visibility: 'off'}
]
}
];
const mapOptions: google.maps.MapOptions = { // this variable gives error
zoom: opts.zoom,
minZoom: opts.zoom,
center: myLatLng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDefaultUI: true,
scaleControl: false,
styles: styleArray,
zoomControl: false,
zoomControlOptions: {
position: google.maps.ControlPosition.BOTTOM_CENTER
}
};
this.map = new google.maps.Map(mapEl, mapOptions);
return this.map;
});
}
错误:
输入'{zoom:number; minZoom:数字;中心:LatLng; mapTypeId:MapTypeId; disableDefaultUI:true; sc ...'不能分配给'MapOptions'类型。属性“样式”的类型是不兼容的。输入'{featureType:string; elementType:string; stylers:{visibility:string; } []; } []'不能赋值为'MapTypeStyle []'。输入'{featureType:string; elementType:string; stylers:{visibility:string; } []; }'不能赋值为'MapTypeStyle'。属性“elementType”的类型不兼容。类型'string'不能分配给'MapTypeStyleElementType'
类型
截图: