[英]Leaflet Center Marker Numbers
有誰知道如何將標記內的數字居中? 這是目前的情況。
創建標記
return L.divIcon({
className: "green-icon",
iconSize: [25, 41],
iconAnchor: [10, 44],
popupAnchor: [3, -40],
html: markerNumber,
});
CSS
.green-icon {
background-image: url("../GreenIcon.png");
background-repeat: no-repeat;
margin: 0 auto;
text-align: center;
color: white;
font-weight: bold;
}
這應該有效。
return L.divIcon({
className: "green-icon",
iconSize: [25, 41],
iconAnchor: [10, 44],
popupAnchor: [3, -40],
html: `<span class="icon-text">${markerNumber}</span>`
})
將此添加到您的 CSS。
.icon-text {
text-align: center;
}
.green-icon {
display: grid;
align-items: center;
}
JSfiddle示例
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.