我只是在学习传单。我能够添加由许多其他多边形组成的多边形。我想为每个多边形添加一个标签。我想添加的标签是mabsurvey @ data $ ID。有33个多边形和标签。
这是我的尝试:
leaflet(as.data.frame(position)) %>%
addTiles() %>%
addPolygons(data = mabsurvey, color = 'grey', opacity = 0.4,label=~mabsurvey@data$ID) %>%
addPolygons(data = accessareas, fill=F,color = 'black', opacity = 0.5) %>%
addPolygons(data = accessareas_c, fill=F,color = 'black', opacity = 0.8) %>%
addCircles(lng = ~long, lat = ~lat, color="red")
答案 0 :(得分:0)
leaflet(as.data.frame(position)) %>%
addTiles() %>%
addPolygons(data = mabsurvey, color = 'grey', opacity = 0.4,popup=paste("Stratum:",mabsurvey@data$STRATA2,"<br>")) %>%
addPolygons(data = accessareas, fill=F,color = 'black', opacity = 0.5) %>%
addPolygons(data = accessareas_c, fill=F,color = 'black', opacity = 0.8) %>%
addCircles(lng = ~long, lat = ~lat, color="red")