In the following map are the locations of schools in Peru, divided by administration type (public or private). Is a little heavy given that there are more than 114,000 circles.
color_function <- colorFactor("Set1", domain = NULL)
mapa <- leaflet(options = leafletOptions(preferCanvas = TRUE)) %>%
addProviderTiles(providers$Esri.WorldGrayCanvas, options = providerTileOptions(
updateWhenZooming = FALSE, # map won't update tiles until zoom is done
updateWhenIdle = TRUE # map won't load new tiles when panning
)) %>%
setView(lat = mean(base$NLAT_IE), lng = mean(base$NLONG_IE), zoom = 5) %>%
addTiles() %>%
addScaleBar()
mapa %>%
addCircleMarkers(lng = base$NLONG_IE, lat = base$NLAT_IE,
color = color_function(base$D_GESTION),
label = base$D_GESTION,
radius = 0.2,
popup = base$CEN_EDU) %>%
addLegend(pal = color_function, values = base$D_GESTION)