Skip to content

Instantly share code, notes, and snippets.

@aagarw30
Last active January 23, 2016 08:05
Show Gist options
  • Save aagarw30/d1484d59adfcd6e3ebda to your computer and use it in GitHub Desktop.
Save aagarw30/d1484d59adfcd6e3ebda to your computer and use it in GitHub Desktop.
R Shiny and Leaflet # 5 - Mapping my birth location - Demo addMarkers() with minimal reproducible example
library(shiny)
library(leaflet)
# we use the renderLeaflet() at the server side for leaflet maps.
shinyServer(function(input, output) {
output$mymap <- renderLeaflet({
# define the leaflet map object
leaflet() %>%
addTiles() %>% # default OSM base map tile
# Define lat , long and zoom level. Pass them into setView as arguments
setView(lng = 82.9739144,lat = 25.3176452, zoom = 2) %>%
# Add location marker to map using addMarkers() function
addMarkers(lng = 82.9739144, lat = 25.3176452, popup = "Varanasi - My Birth Place")
})
})
library(shiny)
library(leaflet)
shinyUI(fluidPage(
leafletOutput("mymap")
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment