Leaflet map not rendering in Shiny

591 Views Asked by At

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?

0

There are 0 best solutions below