I try the Scatter Plots on Maps In R poltly example, that is provided by plotly. https://plot.ly/r/scatter-plots-on-maps/
However, I am not able to get the hover feature to work, when I copied the code and run in rstudio.
library(plotly)
df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_february_us_airport_traffic.csv')
# geo styling
g <- list(
scope = 'usa',
projection = list(type = 'albers usa'),
showland = TRUE,
landcolor = toRGB("gray95"),
subunitcolor = toRGB("gray85"),
countrycolor = toRGB("gray85"),
countrywidth = 0.5,
subunitwidth = 0.5
)
p <- plot_geo(df, lat = ~lat, lon = ~long) %>%
add_markers(
text = ~paste(airport, city, state, paste("Arrivals:", cnt), sep = "<br />"),
color = ~cnt, symbol = I("square"), size = I(8), hoverinfo = "text"
) %>%
colorbar(title = "Incoming flights<br />February 2011") %>%
layout(
title = 'Most trafficked US airports<br />(Hover for airport)', geo = g
)