remove leaflet heatmap layer with rCharts and shiny

前端 未结 1 1240
灰色年华
灰色年华 2021-01-14 12:38

I want to be able to let users see different heatmaps based on a parameter\'s choice in shiny, using rCharts and Leaflet.

The first time the heatmap is displayed it

相关标签:
1条回答
  • 2021-01-14 13:35

    The answer to my problem has been given brilliantly by paulyeno.

    This piece of javascript substitute the lines above:

    tags$body(tags$script(HTML(sprintf("
    var addressPoints = %s
    if (typeof heat === typeof undefined) {
                heat = L.heatLayer(addressPoints, {maxZoom: 9, radius: 20, blur: 40})
                heat.addTo(map)
              } else {
                heat.setOptions({maxZoom: 9, radius: 20, blur: 40})
                heat.setLatLngs(addressPoints)
              }
     </script>",  jsdat
    

    Please note that currently the above code runs in shiny 0.10.1 but not in 0.10.2.1 (bug reported to shiny & rCharts)

    0 讨论(0)
提交回复
热议问题