R: 四日市市役所に葉っぱアイコン, leaflet ver. 3

I.Leafletについて

 

Liefletの使用法をまとめたいと思います。

Leafletはオープンソースで新聞社やGitHubやFlickerでも使われています。

 

Leaflet for R

 

II.地図にポップアップ付きマーカー

 

# import a library
library(leaflet)
# show a map with a marker
m <- leaflet() %>%
addTiles() %>% # Add default OpenStreetMap map tiles
addMarkers(lng=136.6245, lat=34.9652,
popup="四日市市役所")
m
 

 

 

III.影付き葉っぱマーカー

 

# make a custom marker
greenLeafIcon <- makeIcon(
iconUrl = "http://leafletjs.com/examples/custom-icons/leaf-green.png",
iconWidth = 38, iconHeight = 95,
iconAnchorX = 22, iconAnchorY = 94,
shadowUrl = "http://leafletjs.com/examples/custom-icons/leaf-shadow.png",
shadowWidth = 50, shadowHeight = 64,
shadowAnchorX = 4, shadowAnchorY = 62
)
# put an icon of a leaaf with a shadow
m2 <- leaflet() %>%
addTiles() %>% # Add default OpenStreetMap map tiles
addMarkers(lng=136.6245, lat=34.9652,
popup="Nauru",
icon = greenLeafIcon)
m2
 

 

 

 

 

IV.リンク付き文字ポップアップ

 

簡単に文字ポップアップを作成できます。リンクを入れることができますが、ライブラリshinyを使用してHTMLに返還するようです。

 

# popups
content <- paste(sep = "
",
"四日市市役所",
"上は四日市市役所の",
"リンクです"
)
leaflet() %>% addTiles() %>%
addPopups(136.6245, 34.9652, content,
options = popupOptions(closeButton = FALSE)
)
 

 

Please follow and like us:
error

About shibatau

I was born and grown up in Kyoto. I studied western philosophy at the University and specialized in analytic philosophy, especially Ludwig Wittgenstein at the postgraduate school. I'm interested in new technology, especially machine learning and have been learning R language for two years and began to learn Python last summer. Listening toParamore, Sia, Amazarashi and MIyuki Nakajima. Favorite movies I've recently seen: "FREEHELD". Favorite actors and actresses: Anthony Hopkins, Denzel Washington, Ellen Page, Meryl Streep, Mia Wasikowska and Robert DeNiro. Favorite books: Fyodor Mikhailovich Dostoyevsky, "The Karamazov Brothers", Shinran, "Lamentations of Divergences". Favorite phrase: Salvation by Faith. Twitter: @shibatau

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.