リーフレット マップのスタイルを変更したいと考えています。
含めることは可能ですか
- スタイル要素または
- css ファイルへのカスタム パス
RまたはLeafletRのhtmlwidgetsを介して?
一番
リーフレット マップのスタイルを変更したいと考えています。
含めることは可能ですか
RまたはLeafletRのhtmlwidgetsを介して?
一番
質問にコードがまったくないため、回答は非常に困難です。答えてみます。CSS
にカスタムを追加するには、2 つの方法がありますhtmlwidget
。ただし、非常に具体的にする!important
か、オーバーライドを使用する必要があることを前もって警告しますCSS
leaflet
.
簡単だが堅牢性に劣る
htmlwidgets
パッケージtags
から組み合わせることができます。htmltools
library(leaflet)
library(htmltools)
# example from ?leaflet
m = leaflet() %>% addTiles()
# there are two approaches to the custom css problem
# 1. the easy but less robust way
browsable(
tagList(list(
tags$head(
# you'll need to be very specific
tags$style("p{font-size:200%;}")
# could also use url
#tags$link(href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css",rel="stylesheet")
),
m
))
)
htmlDependency でより堅牢に
htmlDependency
重複による競合を処理する を使用することもできます。
# 2. you can add dependencies to your leaflet map
# this mechanism will smartly handle duplicates
# but carries a little more overhead
str(m$dependencies) # should be null to start
#
m$dependencies <- list(
htmlDependency(
name = "font-awesome"
,version = "4.3.0"
# if local file use file instead of href below
# with an absolute path
,src = c(href="http://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css")
,stylesheet = "font-awesome.min.css"
)
)
m