Overview

As a part of the course Developing Data Products’ week 2 assignment, this R markdown document contains a map of Nicaragua with the locations of capital cities of every department that the country has.

Setting the data

As the first part of the creation of the map, it is necessary to load the leaflet package.

library(leaflet)

The dataset required for the map are:

municipalities <- c("Boaco", "Jinotepe", "Chinandega", "Juigalpa", "Puerto Cabezas", "Bluefields", "Estelí", "Granada", "Jinotega", "León", "Somoto", "Managua", "Masaya", "Matagalpa", "Ocotal", "San Carlos", "Rivas")
latitude <- c(12.466667, 11.85, 12.624167, 12.083333, 14.05, 12, 13.083333, 11.93, 13.083333, 12.433333, 13.483333, 12.15, 11.966667, 12.916667, 13.633333, 11.133333, 11.433333)
longitude <- c(-85.666667, -86.2, -87.129722, -85.4, -83.383333, -83.75, -86.35, -85.956111, -86, -86.883333, -86.583333, -86.266667, -86.1, -85.916667, -86.483333, -84.783333, -85.833333)

In this aspect, it is necessary to get every data to form the map and a different geographical marker was uploaded as part of presentation.

geoMark <- makeIcon(
    iconUrl = "https://www.pngkit.com/png/full/444-4449887_place-marker-icon-geo-icon.png",
    iconWidth = 31*215/230,
    iconHeight = 31,
    iconAnchorX = 31*215/230/2,
    iconAnchorY = 16
)
municipalitiesCoord <- data.frame(lat = latitude, lng = longitude)
municipalitiesCoord %>% leaflet() %>% addTiles() %>% addMarkers(icon = geoMark, popup = municipalities)