在标记上的传单弹出窗口中心文本

时间:2017-03-06 15:17:25

标签: r popup leaflet marker

我目前正在使用传单创建地图,我想知道是否可以将文本置于弹出窗口中心?

Here is an example of what a marker currently looks like, as you can see, the writing below starts from the left and I was hoping there's a way to centre the second line.

这是我目前使用它的代码:

map <- leaflet(nodes) %>% addTiles() %>% setView(-0.219067099999961, 51.5122826, zoom=15) %>% addAwesomeMarkers(~lng, ~lat, icon=icons, popup = paste(nodes$group, "<br>", nodes$label))

1 个答案:

答案 0 :(得分:1)

创建css类并应用于弹出文本

var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
var text = document.createElementNS('http://www.w3.org/2000/svg', 'text');
svg.appendChild(text);
document.body.appendChild(svg)
text.getBBox()
/*
[object SVGRect]
*/