The setTemplate(afterscript...) bit setTemplate(afterscript...) does not work brilliant. Instead, you need to use tags$() and display the output of the heat map separately on the map.
Here is a basic application that uses heatmaps ( inspired by this SO answer )
server.R
library(shiny) library(rCharts) dat <- data.frame(Offence = c("Assault","Assault","Assault","Weapon","Assault","Burglary"), Date = c("2015-10-02","2015-10-03","2015-10-04","2015-04-12","2015-06-30","2015-09-04"), Longitude = c(-122.3809, -122.3269, -122.3342, -122.2984, -122.3044, -122.2754), Latitude = c(47.66796,47.63436,47.57665,47.71930,47.60616,47.55392), intensity = c(10,20,30,40,50,30000)) shinyServer(function(input, output, session) { output$baseMap <- renderMap({ baseMap <- Leaflet$new() baseMap$setView(c(47.5982623,-122.3415519) ,12) baseMap$tileLayer(provider="Esri.WorldStreetMap") baseMap }) output$heatMap <- renderUI({
ui.R
library(shiny) library(rCharts) shinyUI(fluidPage( mainPanel( headerPanel("title"), chartOutput("baseMap", "leaflet"), tags$style('.leaflet {height: 500px;}'), tags$head(tags$script(src="http://leaflet.imtqy.com/Leaflet.heat/dist/leaflet-heat.js")), uiOutput('heatMap') ) ))
Edit - Using Google Maps
There is also a way to do this in the googleway development googleway . To do this, you will need a valid Google API key, and currently it only works in a browser
