2

Iam struggling with one letter below the other vertical text orientation for DivIcon. Found some hints/hacks here https://davidwalsh.name/css-vertical-text

But i couldnt manage to get it working for me. My result was that the letters just lay above each other. Is that even supported for DivIcon? Another possibilty would be to create a DivIcon for each letter. But thats very unusual i think.

2

As far as I'm aware, CSS transforms work on block elements, not on inline elements, so you'll have to wrap the contents of your DivIcon into a block element to apply a transform.

Furthermore, Leaflet uses CSS transforms internally to position the marker's icons, so any transform applied to the outer marker container may conflict with any CSS-provided transform.

A more reliable (and easier) way to have "vertical text" is to use the writing-mode CSS property, like so:

/* CSS */
.vertical-text {
   writing-mode: vertical-rl;
}

// JS
var marker = L.marker([0, 0], {
  icon: L.divIcon({
    className: 'vertical-text',
    html: 'Null Island'
  })
});

See a working example here.

1

Like posted in this thread codepen.io/facundocorradini/pen/LxJVNQ and pointed out by IvanSanchez this works fine.

  word-wrap: break-word;
  font-size:1em;
  width:1em;
  padding:0 0.9em;
  box-sizing:border-box;
  text-transform:uppercase;
  cursor: vertical-text;

Just make sure not to add line-height:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.