다른 색깔의 동일한 마커와 함께 총 4 가지 유형의 유형에 따라 Shiny 전단지 점을 매핑해야합니다. Shiny leaflet지도의 맞춤 마커
나는이 체크 :https://rstudio.github.io/leaflet/markers.html
이 내 반응처럼 보이지만, 나는 그것을 고칠 수 :( Change color of leaflet marker
이 코드는 대답
library(dplyr)
library(leaflet)
mutate(quakes, group = cut(mag, breaks = c(0, 5, 6, Inf), labels = c("blue",
"green", "orange"))) -> mydf
### I edit this png file and created my own marker.
### https://raw.githubusercontent.com/lvoogdt/Leaflet.awesome-
markers/master/dist/images/markers-soft.png
quakeIcons <- iconList(blue = makeIcon("/Users/jazzurro/Documents/Stack
Overflow/blue.png", iconWidth = 24, iconHeight =32),
green = makeIcon("/Users/jazzurro/Documents/Stack
Overflow/green.png", iconWidth = 24, iconHeight =32),
orange = makeIcon("/Users/jazzurro/Documents/Stack
Overflow/orange.png", iconWidth = 24, iconHeight =32))
leaflet(data = mydf[1:100,]) %>%
addTiles() %>%
addMarkers(icon = ~quakeIcons[group])
에 공유 된 기본적으로 동일한 코드가 있습니다
# Create our own custom icons
teamIcons <- iconList(
A = makeIcon("C:/Map/Asset 20.png", iconWidth = 18, iconHeight = 18),
B = makeIcon("C:/Map/Asset 21.png", iconWidth = 18, iconHeight = 18),
C = makeIcon("C:/Map/Asset 22.png", iconWidth = 18, iconHeight = 18),
D = makeIcon("C:/Map/Asset 23.png", iconWidth = 18, iconHeight = 18))
DATA1 < - 데이터 %> % (TYPE = 인자 (데이터 $ 타입), C ("A", "B", "C", "D"))
그럼 방금 수행을 돌연변이
m <- leaflet(data=data) %>%
addProviderTiles(providers$Stamen.TonerLite) %>%
addMarkers(~data1$long, ~data1$lat, icon = ~teamIcons[data1$type], popup
state_popup)
addMarkers의 데이터는 데이터가 아닌 data1 (데이터 1)에서 가져옵니다. 멋진 아이콘을 사용할 때 문제가 발생하지 않습니다. 디렉토리에서 내 자신의 아이콘을 사용할 때 맵에 보통 파란색 아이콘이 나타납니다.
잘못된 첨자 형 '논리적'
의이 질문에 대한 답변을 제공하지 않습니다. 충분한 [평판] (https://stackoverflow.com/help/whats-reputation)이 있으면 [모든 게시물에 주석 달기] (https://stackoverflow.com/help/privileges/comment) 할 수 있습니다. 대신, [질문자의 설명이 필요없는 답변을 제공하십시오] (https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can- i-do- 대신). - [From Review] (리뷰/저품절 게시물/18287140) –