Agm Marker 标签不会从我的 markerOptions 数组中获取 marginTop。
<agm-map
[latitude]='latitude'
[longitude]='longitude'
[zoom]='zoomLevel'
>
<agm-marker
*ngFor="let marker of allMarkers"
[latitude]="marker.lat"
[longitude]="marker.lng"
[iconAnchorX]="10"
[iconAnchorY]="10"
[iconHeight]="20"
[label]="marker.labelOption"
[iconWidth]="20"
[iconUrl]="marker.profileImageURL">
</agm-marker>
</agm-map>
我传入的labelOption
(在里面,每个标记都有一个标签和样式)是:allMarkers
allMarkers = [
{
lat: 21.1594627,
lng: 72.6822083,
label: 'Surat',
profileImageURL:'assets/images/map-pin-price.png',
labelOption:{
color: 'white',
fontFamily: '',
fontSize: '14px',
fontWeight: 'bold',
text: "240,000",
marginTop: '10px'
}
},
{
lat: 23.0204978,
lng: 72.4396548,
label: 'Ahmedabad',
profileImageURL:'assets/images/map-pin-price.png',
labelOption:{
color: 'white',
fontFamily: '',
fontSize: '14px',
fontWeight: 'bold',
text: "529,000",
marginTop: '10px'
}
},
{
lat: 22.2736308,
lng: 70.7512555,
label: 'Rajkot',
profileImageURL:'assets/images/map-pin-price.png',
labelOption:{
color: 'white',
fontFamily: '',
fontSize: '14px',
fontWeight: 'bold',
text: "480,323",
lineHeight: '12px',
marginTop: '10px'
}
}
];
现在我得到的结果是:
我想把标签放到图标的中心(给它一个 10px 的 marginTop 或添加一个类将解决这个问题)。