Thomas Kyle
Thomas Kyle

Reputation: 111

Polygon background in leaflet

Is there a way (better in R not to download any additional datasets) how to make polygon (or more visible country borders) in leaflet

Using simple code

m = leaflet() %>%
addProviderTiles("CartoDB.Positron") %>%
addCircles(lat=15,lng=18, radius = 300, color = "blue")

m

Upvotes: 0

Views: 683

Answers (1)

Humpelstielzchen
Humpelstielzchen

Reputation: 6441

There is a world sf-dataset in spData-package.

library(leaflet)
library(sf)
library(spData)

leaflet() %>% 
addProviderTiles("CartoDB.Positron") %>% 
addPolygons(data = world[world$continent == "Europe",], weight = 1)

If you just want the outlines of the countries, use: addPolylines()

enter image description here

Upvotes: 1

Related Questions