簡體   English   中英

Leaflet 中心標記編號

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM