用传单和R向CircleMarkers添加边框 [英] adding border to CircleMarkers with leaflet and R

查看:241
本文介绍了用传单和R向CircleMarkers添加边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为CircleMarkers添加边框.我使用了以下代码.我找不到任何将黑色边框添加到笔触的功能.

I would like to add border to the CircleMarkers. I used the following code. I can't find any function to add black border to the stroke.

pal <- colorNumeric(palette = 'RdYlBu', domain = city_results$ratio)

m <- leaflet() %>% 
     addTiles() %>% 
     setView(lng = median(city_results$long), 
             lat = median(mean(city_results$lat)), 
             zoom = 8) %>% 
     addProviderTiles(providers$CartoDB) %>% 
     addCircleMarkers(data = city_results, lng = ~long, lat = ~lat,
                     radius = ~(Socioeconomic_status_group),
                     color = ~pal(ratio),
                     stroke = TRUE, fillOpacity =  0,
                     popup = ~as.character(nameH),
                     label = ~as.character(round(corr_value,2)),
                     labelOptions = labelOptions(noHide = T, textOnly = TRUE)) 

推荐答案

如果您要使用黑色描边,则以下代码可以完成此工作.我使用了传单包中的地震数据进行了演示.您要使用fillColor填充标记并保存color来为笔划分配颜色.

If you mean that you want to use black color for stroke, the following code does the job. I used the earthquakes data from the leaflet package for this demonstration. You want to use fillColor to fill markers and save color to assign a color to strokes.

library(leaflet)

pal <- colorNumeric(palette = "Blues", domain = quakes$mag)

leaflet() %>% 
addProviderTiles("OpenStreetMap.Mapnik") %>%
addCircleMarkers(data = quakes,
                 radius = ~mag * 5,
                 color = "black",
                 fillColor = ~pal(mag),
                 stroke = TRUE, fillOpacity = 0.5)

这篇关于用传单和R向CircleMarkers添加边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆