Leaflet label style

718 views
Skip to first unread message

Fabio

unread,
Jul 21, 2017, 9:34:49 AM7/21/17
to Shiny - Web Framework for R
Hello,

I was wondering if there is a list somewhere showing all parameters/options available for changing the style of a leaflet label. More specifically, I'd like to remove (or change the color of) that arrow attached to the label border (see examples in the last map here: https://rstudio.github.io/leaflet/popups.html). I was able to remove the border setting labelOptions(style = c("border" = "none")), but had no success changing the arrow.

Thanks!
Fabio

Fabio

unread,
Jul 25, 2017, 5:14:48 PM7/25/17
to Shiny - Web Framework for R
Quick update. I've noticed that labelOptions(style = c("border" = "none")) is resulting in the following message on the server side:

Input to asJSON(keep_vec_names=TRUE) is a named vector. In a future version of jsonlite, this option will not be supported, and named vectors will be translated into arrays instead of objects. If you want JSON object output, please use a named list instead. See ?toJSON.

Not sure how to fix this. Any help would be greatly appreciated.

Thanks,
Fabio

al...@rstudio.com

unread,
Jul 26, 2017, 4:35:43 PM7/26/17
to Shiny - Web Framework for R
Hi Fabio,
I don't think Leaflet labels can be customized to that degree via the R api.

However, one option that might work is by customizing your app via CSS [1]. It looks like you might be able to turn off label arrows by placing this in a custom CSS file:

.leaflet-label-bottom:after, .leaflet-label-top:after, .leaflet-label-right:before, .leaflet-label-left:after { content: none; }

Alan

PS: If you use labelOptions(style = list("border" = "none")) instead of labelOptions(style = c("border" = "none"))  that error should go away.

Fabio

unread,
Jul 26, 2017, 4:54:35 PM7/26/17
to Shiny - Web Framework for R
Hi Alan,

It worked like a charm. Thanks a lot! Is there a document somewhere describing the CSS options?

Thanks again,
Fabio

al...@rstudio.com

unread,
Jul 27, 2017, 1:52:57 PM7/27/17
to Shiny - Web Framework for R
Hi Fabio,
Glad to hear. Re: CSS - probably, but not that I'm aware of. Winston Chang is the one who actually found the solution using Google Chrome developer tools, a technique that seems ideal.
Alan
Reply all
Reply to author
Forward
0 new messages