0

Leaflet map not rendering for the below code. Also state how the map should fit to the width of the box in shiny dashboard. It retrieves the tweets but not rendering.

server.R

mapPlot <- function(searchTerm, maxTweets, lang, lat, long, rad){
   mapTweets <- searchTwitter(searchTerm, maxTweets, lang = "en", geocode = paste(lat,long,paste0=(rad,"mi"),sep="'")
    mapTweets.df <- twListToDF(mapTweets)
    return(mapTweets.df)
  }

  entity13 <- eventReactive(input$mapit,{

    entity13 <- mapPlot(input$k, input$nt, lang = "en", input$lat, input$long, input$rad)
    entity13
  })





   output$mymap <- renderLeaflet({

    m <- leaflet(entity13()) %>%  addTiles() %>% # addCircles(ct$longitude, ct$latitude, weight = 20, radius=50, color="#000000", stroke = TRUE,  fillOpacity = 0.8) 
      addMarkers(entity13()$longitude, entity13()$latitude, popup = entity13()$screenName)

    # m %>% addPopups(~longitude, ~latitude, ~text)  

    m %>% setView(entity13()$longitude, entity13()$latitude, zoom = 4)
    return(m)
    })

ui.R

column(width = 8,
                         box(width = NULL, leafletOutput("mymap",height="500px"), collapsible = TRUE,
                             title = "Visualization of the place where the tweets popped from", status = "primary", solidHeader = TRUE)
                  )

Leaflet map is not rendering.

Is there a solution to this?

Solomon AathiRaj
  • 119
  • 1
  • 10
  • try `geocode = paste(lat,long,rad,sep=",")` – cory Mar 30 '16 at 15:40
  • Now its showing this: (it's not properly working) `Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit = retryOnRateLimit, : 100 tweets were requested but the API can only return 0 Warning: Error in twListToDF: Empty list passed to twListToDF` but when I run the searchTwitter individually in the console with the same values, it works @cory – Solomon AathiRaj Mar 30 '16 at 18:18
  • If I remember correctly, the lat, long, rad was very specific about spaces. Make sure you are providing those values per the API spec. – cory Mar 30 '16 at 18:22
  • actual format should be like this : `geocode = '13,80,500mi'` @cory – Solomon AathiRaj Mar 30 '16 at 18:28
  • Is that what your input looks like after you `paste` your lat,long, rad together? You may have to do something like: `geocode = paste(lat,long,paste0(rad, "mi"),sep=",")` – cory Mar 30 '16 at 18:30
  • it works. but not rendering the leaflet map. I updated the code @cory check it – Solomon AathiRaj Mar 30 '16 at 18:32

0 Answers0