Version 21 (modified by Martin Scharrer, 7 years ago) (diff)


Insert a static Google Map as image


This macro uses the Google Map API to include static images of maps. Static means that is is only a simple image without any user interaction not the usual feature-rich dynamic map on The positive side is that no javascript is needed to display the map image.

For a dynamic Google map use the GoogleMapMacro.

Please note that the maximum size supported by Google is 640x640 pixels. If a bigger width or height is requested it will be reduced to 640px.

The macro should work both with Trac 0.11 and 0.12. At the moment there is only a 0.11 directory which can also be used for Trac 0.12. The AdvParseArgsPlugin is used to allow for quoted argument values and must also be installed.

Bugs/Feature Requests

Existing bugs and feature requests for GoogleStaticMapMacro are here.

If you have any issues, create a new ticket.


Download the macro as [download:googlestaticmapmacro/0.11 ZIP-file].


You can check out GoogleStaticMapMacro from here using Subversion, or browse the source with Trac.

Installation & Configuration

Install the plugin as usual.

To enable the macro put the following into your trac.ini file, which is located in the config directory of your trac installation. You need to restart trac to reread the macro file and the configuration file.

tracgooglestaticmap.* = enabled

api_key = <Your Google API key (long hex number)>  # not required for API v2
# Optional settings:
#default_size = 300x300
#default_language = de
#default_api_version = <1 or 2> # should be 2 for newer installations. Set to 1 if you want to keep older macros unchanged

Upgrade from older Versions

The current version of the macro uses the Google Static Map API v2, while older versions used API v1 (Upgrade guide). The syntax provided by Google has changed between the API versions. In order to provide the newer features but also not break existing macros both API versions are supported using the api key. The older syntax can still be used with newer versions of the macro by setting api=1 either as a macro argument ([[GoogleStaticMap(api=1,<old syntax>)]]) or using the global configuration option default_api_version.

Please note, that since v2 an API key is not required anymore by Google. The API v1 still requires a trac server specific Google Map API key which is provided by Google for free.

Usage & Examples

This documentation describes the syntax for the macro v1.x which uses Google's API v2 (see #Upgrade). The older syntax is still supported using the api=1 argument. See an older version? of this wiki page for the old syntax. Mixing of older and newer syntax is not supported.


The macro accepts the official Google Static Map argument (see there) as well as a few internal arguments:

Sets the HTML title of the map image.
Sets the API version to be used. By default set to "2". To reuse the older macros set api=1 as mentioned earlier.
Sets the API key if not set globally in the config file. Deprecated for macro v1.x / Google API v2.

All map locations (center, markers, path) can now be given as address or geographic coordinates (latitude,longitude). Please note that addresses and coordinates must be quoted using double-quotes (") when they include a comma. This is always the case with coordinates. The old macro syntax used colons (:) as substitutes, which no longer supported in the new syntax.

For example:


will both result in the following map image:


You can add markers to the static map using the 'markers' argument. The format is 'markers=style settings|first location|next location|...' (details), e.g.: markers="size:mid|label:A|color:blue|50.805935,10.349121", creates a blue marker labeled with 'A' at 50.805935,10.349121. Again also addresses can be used to specify locations. The whole value must be quoted if any commas are included. Multiple markers arguments can be given to add markers with different styles.



will result in the following map image:


Paths between locations can be added using the path argument which has basically the same syntax as markers, except different styles are supported. See the Google documentation for details.

Processor Syntax

While Tracs normal macro syntax ([[Macro(key=value,key=value)]]) is nice for smaller arguments lists it is getting messy for longer lists. This macro now also supports the so called wiki processor syntax ({{{ <linebreak> #!Macro <linebreak> content <linebreak> }}}) to allow for multiple lines of arguments. In this case a line break will be read as a comma:

key2="value 2, with comma"

is identical to:

[[GoogleStaticMap(key1=value1,key2="value 2, with comma",key3=value3,key4=value4)]]




Recent Changes

15264 by rjollos on 2016-02-11 04:22:34
Remove unnecessary svn:mime-type on py files

svn:mime-type was set to "plain" for many files.

8571 by martin_s on 2010-08-31 18:02:58
Increaded version number to indicate major change due to Googles API change.
Fixed colon substitution for markers for api=1.
8570 by martin_s on 2010-08-31 17:40:58
Made colon-to-comma substitution active only for API v1.


Author: martin_s
Maintainer: martin_s