Skip to content

Instantly share code, notes, and snippets.

View pvictor's full-sized avatar

Victor Perrier pvictor

View GitHub Profile
@PaulC91
PaulC91 / addCircleLegend.R
Created March 31, 2020 11:18
Add a custom circle legend to leaflet map in R
#' Add custom circle legend to leaflet map
#'
#' To be used alongside \code{leaflet::addCircleMarkers}
#'
#' @param map a leaflet map
#' @param title title of the legend
#' @param range vector of numeric values you want to scale the legend to (same vector used with addCircleMarkers)
#' @param scaling_fun the scaling function used with addCircleMarkers to scale circle radii appropriately for leaflet
#' @param color stroke color
#' @param weight stroke width in pixels
library(leaflet)
library(sf)
library(rmapshaper)
library(dplyr, warn.conflicts = FALSE)
library(smoothr)
library(shiny)
u <- httr::GET('https://www.data.gouv.fr/api/1/datasets/5e7e104ace2080d9162b61d8/')
url_search <- httr::content(u)$resources