[This article was first published on Software for Exploratory Data Analysis and Statistical Modelling » R Environment, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The ggmap package can be used to access maps from the Google Maps API and there are a number of examples on various statistics related blogs. These include here, here and here.

The ggmap package has a function get_map that can download maps from various sources including Google Maps.

`require(ggmap)`

The first example specifies the longitude and latitude close to the London 2012 Olympic park from Google and selects the satellite map type. The extent=”device” argument stretches the map to fill the whole graphics device.

```mapImageData1 <- get_map(location = c(lon = -0.016179, lat = 51.538525), color = "color", source = "google", maptype = "satellite", zoom = 17)   ggmap(mapImageData1, extent = "device", ylab = "Latitude", xlab = "Longitude")```

The second example is based on the terrain map type which looks slightly odd.

```mapImageData2 <- get_map(location = c(lon = -0.016179, lat = 51.538525), color = "color", source = "google", maptype = "terrain", zoom = 16)   ggmap(mapImageData2, extent = "device", ylab = "Latitude", xlab = "Longitude")```

The third example is roadmap and is uncluttered and provides an overview of the surroundings.

```mapImageData3 <- get_map(location = c(lon = -0.016179, lat = 51.538525), color = "color", source = "google", maptype = "roadmap", zoom = 16)   ggmap(mapImageData3, extent = "device", ylab = "Latitude", xlab = "Longitude")```

The final example is a combination of the satellite image and some road and location names.

```mapImageData4 <- get_map(location = c(lon = -0.016179, lat = 51.538525), color = "color", source = "google", maptype = "hybrid", zoom = 15)   ggmap(mapImageData4, extent = "device", ylab = "Latitude", xlab = "Longitude")```