Skip to content

Instantly share code, notes, and snippets.

@aagarw30
Last active January 23, 2016 08:04
Show Gist options
  • Save aagarw30/5821ec4c951669eb3c04 to your computer and use it in GitHub Desktop.
Save aagarw30/5821ec4c951669eb3c04 to your computer and use it in GitHub Desktop.
R Shiny and Leaflet # 4 - A simple map which demos setView() and addMarkers() functions and mapping "Taj Mahal, Agra, India"
library(shiny)
library(leaflet)
## renderLeaflet() is used at server side to render the leaflet map
shinyServer(function(input, output) {
output$mymap <- renderLeaflet({
# define the leaflet map object
leaflet() %>%
addTiles() %>%
setView(lng = 78.0419, lat = 27.1750 , zoom = 15) %>%
addMarkers(lng = 78.0419, lat = 27.1750, popup = "Taj Mahal, Agra, India") # uncomment following if want to have a pop up %>%
# addPopups(lng = 78.0419, lat = 27.1750, popup = "Taj Mahal, Agra, India")
})
})
library(shiny)
library(leaflet)
## leafletOutput is used at the ui side to display the rendered map.
shinyUI(fluidPage(
leafletOutput("mymap")
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment