还在学习打字稿,我有这个对象
export class Marker {
position: {
lat: number,
lng: number,
};
label: {
color: string,
text: string,
};
title: string;
options: {
animation: any,
};
}
在我使用它的代码中,我这样做了,但是 marker.position 是未定义的
for (const ybEvent of this.Events) {
const marker = new Marker();
marker.title = ybEvent.name;
marker.position.lat = ybEvent.latitude;
marker.position.lng = ybEvent.longitude;
marker.label.color = 'blue';
marker.label.text = ybEvent.description;
marker.options.animation = google.maps.Animation.BOUNCE;
this.markers.push(marker);
}
在这个对象中初始化位置、标签和选项的最佳方法是什么?
