Skip to content

Instantly share code, notes, and snippets.

@StevenMMortimer
Created November 24, 2015 17:57
Show Gist options
  • Save StevenMMortimer/2af90ea619ec564d7174 to your computer and use it in GitHub Desktop.
Save StevenMMortimer/2af90ea619ec564d7174 to your computer and use it in GitHub Desktop.
library(devtools)
install_github('ReportMort/leaflet')
library(leaflet)
m <- leaflet()
m <- addTiles(m)
m <- addMarkers(m, lng=174.768, lat=-36.852, popup="The birthplace of R", layerId='layer1')
m <- addMarkers(m, lng=174.788, lat=-36.852, popup="East of the birthplace of R", layerId='layer2')
m
# test toggle open
m <- toggleMarkerPopup(m, 'layer1')
m
# test toggle close
m <- toggleMarkerPopup(m, 'layer1')
m
# test open
m <- openMarkerPopup(m, 'layer2')
m
m <- openMarkerPopup(m, 'layer1')
m
# test close
m <- closeMarkerPopup(m, 'layer1')
m
# test passing vector of content
m <- setMarkerPopupContent(m, c('layer1', 'layer2'), c('New Content 1', 'New Content 2'))
m
# test element recycling
m <- setMarkerPopupContent(m, c('layer1', 'layer2'), c('New Content 1'))
m
# test unbind
m <- unbindMarkerPopup(m, c('layer1', 'layer2'))
m
# test clear marker popups (clears bound popups, not ones added using addPopups)
m <- clearMarkerPopups(m)
m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment