I am trying to create map of California state following the ggmap link. However,when I am running the below code it is giving me below error.
get_map(location ='california',zoom =4)
Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=california&zoom=4&size=640x640&scale=2&maptype=terrain&language=en-EN&sensor=false Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=california&sensor=false 1280x1280 terrain map image from Google Maps. see ?ggmap to plot it.
In addition, I am planning on trying to plot some location on same map. Any help is much appreciated.
My dataset for plotting latitude and longitude looks like following:
structure(list(hotel_name = structure(c(1L, 5L, 2L, 4L, 3L), .Names = c("h1_Loc",
"h2_Loc", "h3_Loc", "h4_Loc", "h5_Loc"), .Label = c("Grand Hyatt San Diego",
"Grand Hyatt San Francisco", "Hyatt Regency Orange County", "Hyatt Regency Sacramento",
"Hyatt Regency San Francisco"), class = "factor"), longi = c(-117.1687,
-122.3954, -122.4073, -121.4908, -117.9164), lati = c(32.70974,
37.79459, 37.78922, 38.57763, 33.78932)), .Names = c("hotel_name",
"longi", "lati"), row.names = c("h1_Loc", "h2_Loc", "h3_Loc",
"h4_Loc", "h5_Loc"), class = "data.frame")
get_map()
per the documentation, returns aggmap
object. To plot it, you will want to useggmap
. For example,ggmap(get_map(location ='california', zoom=4))
. Alternatively,cali <- get_map(location ='california', zoom=4); ggmap(cali);
. – JasonAizkalnsmy_points <- data.frame(lon = c(-120, -116), lat = c(36, 33)); ggmap(get_map(location = 'California', zoom = 6, maptype = "roadmap")) + geom_point(aes(x = lon, y = lat), data = my_points, color = "red")
– JasonAizkalns