Skip to content

Instantly share code, notes, and snippets.

@aleszu
Created December 18, 2018 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aleszu/e266049c4de08880a039aae9560eccd4 to your computer and use it in GitHub Desktop.
Save aleszu/e266049c4de08880a039aae9560eccd4 to your computer and use it in GitHub Desktop.
library(tidyverse)
library(leaflet)
library(geojsonio)
library(htmlwidgets)
library(htmltools)
nycmarkers <- read.csv("nycmarkers.csv", stringsAsFactors=F) # with "lat", "lon" and "string" columns
nycshapefile <- geojsonio::geojson_read("nycshapefile.geojson", what = "sp")
nycmap <- leaflet(nycmarkers) %>%
addProviderTiles("CartoDB.Positron") %>%
setView(-73.978241, 40.698266, zoom = 12) %>%
addPolygons(data=nycshapefile,
col = 'firebrick',
stroke = FALSE,
fillOpacity = 0.5,
smoothFactor = 0.5) %>%
addCircleMarkers(label=~string,
#labelOptions = labelOptions(noHide = T),
popup = ~htmlEscape(string),
weight = 3,
radius=8,
color="#999999"
)
nycmap
saveWidget(nycmap, file="nycmap.html", selfcontained = FALSE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment