0x4*_*x45 5 javascript css markers leaflet
我想在标记的中心(内部)显示工具提示。
我想显示每个标记的计数(第一个 - > 最后一个),我发现我可以用工具提示来做到这一点(任何更好的建议)
所以我的标记现在看起来像这样,
var marker = L.marker(latlng, {icon: blueIcon}).bindTooltip(feature.properties.count,
{
permanent: true,
direction: 'right'
});
Run Code Online (Sandbox Code Playgroud)
我找不到任何关于方向centered或类似的进一步文档。
工具提示提供了查看第一个和最后一个标记的功能,但这似乎不是最佳实践。
所以我的问题:
(在这里,我将背景设置为隐形,以便我可以看到文本。)
我发现你可以添加direction: center. 参考: http: //leafletjs.com/reference-1.0.0.html#tooltip-direction
我已经用DivIcon解决了我的问题
var numberIcon = L.divIcon({
className: "number-icon-default",
iconSize: [25, 41],
iconAnchor: [10, 44],
popupAnchor: [3, -40],
html: feature.properties.count
});
Run Code Online (Sandbox Code Playgroud)
像这样的CSS
.number-icon-default
{
background-image: url("#{request.contextPath}/lib/leaflet/images/marker-icon.png");
text-align:center;
color:Black;
text-shadow: 1px 1px #000000;
font-size: large;
font-weight: bold;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11330 次 |
| 最近记录: |