0

I have a shiny app in which I plot a map with plotGoogleMaps and a rChart, with values related to some markers in the map, rendered via rPlot.

The app user can click on a marker in the map to show a tooltip.

I'd like that when he clicks on the marker, the pertinent value in the chart would be highlighted.

Anybody knows how to perform this task?

Thank you.

jdharrison
  • 30,085
  • 4
  • 77
  • 89
  • 1
    Please provide a minimal reproducible example. – jdharrison Jul 02 '14 at 12:29
  • I posted this question when sick at home, so I have not the code at hand !! The problem is: how to extract a value from the html page used by plotGoogleMaps and return it to the global environment so that it can be used on the server side. – user3756340 Jul 02 '14 at 14:55

1 Answers1

0

@jdharrison

The R-code can be like this:

suppressPackageStartupMessages(library(googleVis))

## Hurricane Andrew (1992) storm track with Google Maps
AndrewMap <- gvisMap(Andrew, "LatLong", "Tip", options = list(showTip = TRUE, 
showLine = TRUE, enableScrollWheel = TRUE, mapType = "hybrid", useMapTypeControl = TRUE))

print(AndrewMap, "chart")

The example was taken from here. You can download the package here. In this example, library googleVis is used, but I think that the answer can be similar.

Shiny example

server.R

# Author: Denis Petrov
# Date: 2014-07-04

# Example is based on http://rpubs.com/gallery/googleVis

library (shiny)
suppressPackageStartupMessages (library (googleVis))

# Define server logic required to summarize and view the selected dataset
shinyServer ( function (input, output, session) 
{
  GetDataAndrew <- function ()
  {

    # Hurricane Andrew (1992) storm track with Google Maps
    AndrewMap <- gvisMap (Andrew, "LatLong", "Tip", 
                         options = list(showTip = TRUE, 
                                        showLine = TRUE, 
                                        enableScrollWheel = TRUE, 
                                        mapType = "hybrid", 
                                        useMapTypeControl = TRUE))

    return (AndrewMap)

  }

  output$viewchart <- renderGvis({
    GetDataAndrew ()
  })

  output$info <- renderPrint ({
    cat ('Hurricane\n')
    cat ('Pressure=937\n')
    cat ('Speed=120')
  })

}
)

ui.R

# Author: Denis Petrov
# Date: 2014-07-04


# Define UI for dataset viewer application
shinyUI(pageWithSidebar(

  # Application title
  headerPanel('Hurricane Andrew (1992)'),

  # Sidebar with controls to provide a caption, select a dataset, and 
  # specify the number of observations to view. Note that changes made
  # to the caption in the textInput control are updated in the output
  # area immediately as you type
  sidebarPanel(
               p ('Hurricane Andrew (1992) storm track with Google Maps'),
               p ('I would like the following output be changed based on 
                  selected pin.'),
               verbatimTextOutput ('info')
  ),


  # Show the caption, a summary of the dataset and an HTML table with
  # the requested number of observations
  mainPanel(
    htmlOutput ('viewchart')
  )
))
Community
  • 1
  • 1
dStack
  • 73
  • 1
  • 7