RgoogleMaps and ggmap producing blank plot

510 Views Asked by At

I am trying to use the RgoogleMaps package in R. I am running R version 3.1.0 on Windows Server 2008. No matter what I try to plot, I keep getting just a blank plot. I have tried writing out to external devices such as pdf or png with no luck. Here is an example:

BrooklynMap <- GetMap(center="Brooklyn", zoom=13)
PlotOnStaticMap(BrooklynMap)

This plots just find on my laptop, but it just gives a blank plot on my Windows Server 2008 machine. I have also tried to use the ggmap package with the following code:

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")

Again, this works on my laptop but produces just a blank plot on Windows Server 2008.

Can anyone provide guidance as to what might be causing this?

Thank you, Sam

2

There are 2 best solutions below

0
On

Try to use an explicit print() statement with the ggmap() command, e.g. like so:

print(ggmap(mapImageData3, extent = "device", ylab = "Latitude", xlab = "Longitude"))

Also, make sure you have the latest version of ggmap installed.

0
On

With this code I was able to get the plot to save to a file:

BrooklynMap <- GetMap(center="Brooklyn", zoom=13,destfile = "MyTile3.png")
PlotOnStaticMap(BrooklynMap)

I was trying to use png() to produce the output, and that didn't work. To be clear, it still doesn't plot interactively in R.