Creating an interactive map

The map is created by using the leaflet library.

library(leaflet)

To show the date of today, we print it:

date()
## [1] "Thu Apr 12 17:06:50 2018"

Our interactive maps is based on the dataframe FlevoCities containing the geo position and the population of the cities in the Dutch province of Flevoland.

FlevoCities <- data.frame( lat=c(52.366667, 52.516667, 52.5, 52.716667, 52.65, 
                                 52.333333), lng=c(5.216667, 5.716667, 
                                                   5.466667, 5.7, 5.6, 5.533333), 
                           pop = c(201700, 40711, 77095, 46573, 20342, 22452), 
                           mun =c("Almere", "Dronten", "Lelystad", 
                                  "Noordoostpolder", "Urk", "Zeewolde"))

We further have a character vector FlevoURL containing the URLs of the local governments of these cities:

FlevoURL <- c("<a href='http://www.almere.nl/'>Almere</a>", "<a href='https://www.dronten.nl/mozard/!suite05.scherm1428?mNch=uhbzefhcuh'>Dronten</a>","<a href='https://www.lelystad.nl/Inwoner'>Lelystad</a>","<a href='https://www.noordoostpolder.nl/'>Noordoostpolder</a>","<a href='https://www.urk.nl/'>Urk</a>","<a href='https://www.zeewolde.nl/gemeente'>Zeewolde</a>")

The intercative map is created by the following command:

FlevoCities  %>% 
        leaflet() %>%
        addTiles() %>%
        addCircleMarkers(weight=1, radius=sqrt(FlevoCities$pop)*0.25, popup = FlevoURL, clusterOptions = markerClusterOptions())
## Assuming 'lng' and 'lat' are longitude and latitude, respectively

The circles are sized relatively to the population size, the circles are clustered once you zoom out, and the centre of each circle contains a link to the local government.

Cheers!