Skip to content

Commit 9330ae9

Browse files
committed
One more example
1 parent 2199285 commit 9330ae9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

inst/examples/geojson.R

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
library(leaflet)
3+
library(sp)
34
#' <br/><br/>
45
#' The V8 part is simply to read the JSON embeded in the Javascript.<br/>
56
#' For a geojson file `jsonlite::fromfromJSON()` or `geojsonio::regeojson_read()` will do
@@ -25,3 +26,18 @@ leaflet() %>% addTiles() %>%
2526
icon = ~icons[amenity],
2627
options = markerOptions(riseOnHover = TRUE, opacity = 0.75),
2728
group = 'pubs')
29+
30+
31+
#' <br/><br/>
32+
#' Another examples this time with polygons
33+
url <- 'http://www.partners-popdev.org/wp-content/themes/original-child/vendor/Geojson/States/Maharashtra.geojson'
34+
35+
mhSPDF <- geojsonio::geojson_read(url, what="sp")
36+
37+
cols <- colorFactor(topo.colors(nrow(mhSPDF)),mhSPDF$NAME_2)
38+
39+
leaflet() %>% addProviderTiles(providers$Stamen.TonerLite) %>%
40+
setView(75.7139, 19.7515, 6) %>%
41+
addPolygons(data=mhSPDF, opacity = 5,
42+
label=~NAME_2, weight = 1,
43+
fillColor = ~cols(NAME_2))

0 commit comments

Comments
 (0)