Question

How can I suppress Google's messages in an output .pdf when using ggmap with a knitr .Rnw file? MWE code for .Rnw file used to generate a .pdf illustrating the issue:

\documentclass{article}
\begin{document}
<<>>=
library(ggmap)
qmap("empire state building", zoom=15, messaging=FALSE, source="google") 
@
\end{document}

In the resulting .pdf, the following (poorly formatted) messages appear:

Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=empire+state+building&zoom=15&size=%20640x640&scale=%202&maptype=terrain&sensor=false
Google Maps API Terms of Service : http://developers.google.com/maps/terms  
Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=empire+state+building&sensor=false  
Google Maps API Terms of Service : http://developers.google.com/maps/terms  

How can these messages be suppressed? I was hoping messaging=FALSE would do this.

Was it helpful?

Solution

You can supress any messages for a code chunk using message = FALSE

<<themap, message = FALSE>>=
library(ggmap)
qmap("empire state building", zoom = 15, messaging = FALSE, source = "google") 
@

Suppresses these messages.

Looking at ggmap::qmap, it evaluates the arguments in ... in what might be considered a non-standard way to allow the different sources to be used. It appears that verbose (an argument to RgoogleMaps::GetMap does not get parsed or passed, nor does messaging (an argument to get_googlemap`)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top