Skip to content

Multilines for Labels #58

Answered by ccll
DDaehn asked this question in Q&A
Discussion options

You must be logged in to vote

Same problem here, and found a workaround to this with some JS DOM magic.
Just find the label elements and replace the innerHTML with multiline <tspan> elements:

const labelGroupElement = document.getElementById('jvm-markers-labels-group')
if (labelGroupElement) {
    for (const child of labelGroupElement.children) {
        const markerName = child.innerHTML
        const location = data.locations.find(
            (marker) => marker.displayLocation === markerName,
        )
        const region = location?.displayRegion
        const x = child.getAttribute('x')
        child.innerHTML = `
            <tspan x="${x}" dy="-0.3em" font-size="16" font-weight="bold">${markerName}</tspan>

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by themustafaomar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants