I am making a shiny app that has a map. On the map are some circles, and in the addCircles command there is a layerId. Lets call the data that makes the circles CircleData() - its reactive, and the Id is CircleName. I want to use the popup= argument to add a popup that uses the CircleName of that particular circle to run a function, which then returns some text for the popup. Different circles will get different text. depending on the ID. I have tried
1)
addCircles(data=CircleData(),layerId=CircleData$Name, popup=paste( MyFuction(x=CircleData()$CircleName) ) )
This creates the circles correctly, but passes the entire CircleData()$CircleName column to MyFuction, rather than just the value for one particular circle.
2)
addCircles(data=CircleData(), layerId=CircleData$Name, popup=paste( MyFuction(x=~CircleName) ) )
This crashes as it does not read ~CircleName as a character input, but rather an input of type 'language'
3)
addCircles(data=CircleData(), layerId=CircleData$Name, popup=paste( MyFuction(x=input$MyMap_shape_click$id) ) )
Close, I think. If I use this code in a panel elsewhere in the app, I get the correct output. In a popup, however, the popup briefly flashes the correct output, and then disappears. I think I am establishing a reactive link between the circles and input$MyMap_shape_click$id that is causing the circles to be redrawn every time I click the map.
4)
addCircles(data=CircleData(), layerId=CircleData$Name, popup=isoalte(paste( MyFuction(x=input$MyMap_shape_click$id) ) ) )
putting an isolate around the whole popup does not work. It seems that the function does not get run at all.Same thing happens if I do an isolate just around MyFunction.
So - any ideas how to pass the CircleName, but not redraw the circles?
Thanks