File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 1
1
2
2
library(leaflet )
3
+ library(sp )
3
4
# ' <br/><br/>
4
5
# ' The V8 part is simply to read the JSON embeded in the Javascript.<br/>
5
6
# ' For a geojson file `jsonlite::fromfromJSON()` or `geojsonio::regeojson_read()` will do
@@ -25,3 +26,18 @@ leaflet() %>% addTiles() %>%
25
26
icon = ~ icons [amenity ],
26
27
options = markerOptions(riseOnHover = TRUE , opacity = 0.75 ),
27
28
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 ))
You can’t perform that action at this time.
0 commit comments