[Tex/LaTex] How to embed a Google Map

embeddinggetmaphtml

Is there a way to embed the HTML code that Google Maps provide to embed your map in your pdf using LaTeX?

The source HTML code looks like this:

<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3036.4313574576963!2d-79.9457446846033!3d40.44358877936194!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x8834f2219059e091%3A0x47888be8ae0bea3a!2s5000+Forbes+Ave%2C+Pittsburgh%2C+PA+15213!5e0!3m2!1sen!2sus!4v1445448752174" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>

Best Answer

You can use the getmap package. It offers an interface to Google Maps' Static Image API!

\documentclass[margin=10pt]{standalone}
\usepackage{graphicx}
\usepackage[overwrite=true,mode=gm]{getmap}
\begin{document}
\getmap[file=pittsburgh,
        color=blue,
        number=A,
        xsize=600,
        ysize=450,
        zoom=16,
        scale=2]
       {Forbes Ave, Pittsburgh, USA}
\includegraphics[width=5cm]{pittsburgh}
\end{document}

enter image description here

getmap needs the \write18 feature enabled, therefore you must compile the file with the -shell-escape switch, e.g.:

pdflatex -shell-escape testfile

getmap offers much more incl. interfaces to Open Street Map and Google Streetview.

For details take a look into getmap's documentation (texdoc getmap) or its wiki!

Related Question