Version 15 (modified by martin_s, 8 years ago) (diff)

Added usage description for server side geocoding

Inserts a dynamic Google Map into wiki pages


This macro lets the user insert a full dynamic Google Map. Because a lot of javascript is used (by Google) a Google Map compatible browser is needed. Newer version of Firefox and MS Internet Explorer are compatible.

For javascript-less static maps use the similar GoogleStaticMapMacro.

Please note that this is an alpha version which still lacks some functionality.

Multiple Google Maps on the same wiki page are actively supported.

Feedback: I would like to get some user feedback for this macro. Tell me if you like it or not and what could be better. Feel free to request additional features as long there are supported by the Google Maps API by opening a feature request.

Bugs/Feature Requests

Existing bugs and feature requests for GoogleMapMacro are here.

If you have any issues, create a new ticket.


Download the zipped source from [download:googlemapmacro here].


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

There is a develop version which can be unstable: check-out | browse

Installation & Configuration

Just copy the python file in the plugin directory of your trac installation.

A different Google Map API key is needed for every web domain which can be get for free from Google.

To enable the macro put the below text into your trac.ini file, which is located in the config directory of your trac installation. You can define project wide default values for some arguments and also whether the geocoding (address-to-coordinates conversion) is done on by the trac server or by the clients web browser. Google recommends server side geocoding with caching which is now implemented and can be enabled using geocoding = server. Please note that this creates a table 'googlemapmacro' in your trac database which is used for the caching. Server side geocoding is recommended but disabled by default.

You need to restart trac to reread the macro file and the configuration file.

googlemap.* = enabled

api_key = <Your Google API key (long hex number)>
## Server side geocoding (address-to-coordinates conversion) incl. caching (recommended).
## Please note that this creates a table 'googlemapmacro' in your trac database.
## Possible settings are 'server' or 'client' (without the quotes). Default is 'client' in order not to change the DB unasked.
#geocoding = server
## Optional default settings:
#default_size = 400x400
#default_zoom = 6


The macro knows the following arguments, which can be used in the normal 'key1=value1,key2=value2,...' syntax.

address (or no key)
Sets the center of the map to the given address. Please use semi-colons (';') to separate the street, city and country. The value can be surrounded by quotes, e.g. "Street; City; Country".
Sets the center of the map to the given coordinates. The format is {longitude}:{latitude}.
Sets zoom factor. Allowed values are between 0 (whole world) and 19 (single house). Very high zoom values might not be supported by Google Maps for all parts of the world.
The size in the format {width}x{height} as numbers in pixel, e.g.: 300x300 means 300px width and height.
types (optional)
Sets the map types selectable by the user, separated by colons (':'). If not given the standard types of Google Maps are used (Normal, Satellite, Hybrid). The following types are available (values are case-insensitive):
  • normal Normal street-map
  • satellite Satellite picture
  • hybrid Satellite picture with streets as overlay
  • physical Terrain map
type (optional)
Sets the initial map type. See the types argument for the available types. If this argument is not given the first listed type under types is used initially.
controls (optional)
Sets the used map controls. Multiple controls can be given, separated by colon (':'). If not set the controls MapType and LargeMap are used. If set but empty no controls are displayed. The following controls are available (descriptions taken from the Google Map API page):
  • LargeMap: Control with buttons to pan in four directions, and zoom in and zoom out.
  • SmallMap: Control with buttons to pan in four directions, and zoom in and zoom out, and a zoom slider.
  • SmallZoom: Control with buttons to zoom in and zoom out.
  • Scale: Control that displays the map scale.
  • MapType: Standard map type control for selecting and switching between supported map types via buttons.
  • HierarchicalMapType: Drop-down map type control for switching between supported map types.
  • OverviewMap: Collapsible overview mini-map in the corner of the main map for reference location and navigation (through dragging).


Using geographic coordinates

Please use a colon, not a comma, as separator for the coordinates.


Using an address

Please use semicolons, not commas, as separators in the address.

[[GoogleMap(address="Street; City; County",zoom=10,size=400x400)]]


[[GoogleMap("Street; City; County",zoom=10,size=400x400)]]

Please note that the address is converted into coordinates by user-side javascript every time the wiki page is loaded. If this fails no map will be shown, only an empty gray rectangle.

Server side address conversion including caching is underway.

Using both

If both address and center coordinates are given, then the result depends on the `geocoding` setting:

The address is resolved on the trac server and the coordinates are completely ignored.
The map is first centered at the given coordinates and then moved to the given address after (and if) it was resolved by the client-side JavaScript code.

[[GoogleMap(center=50.0:10.0,address="Street; City; County",zoom=10,size=400x400)]]

Select Map Types

To show a map with the standard map types where the satellite map is preselected:

[[GoogleMap("Street; City; County",zoom=10,size=400x400,type=satellite)]]

To only show a satellite map (please note the added 's'):

[[GoogleMap("Street; City; County",zoom=10,size=400x400,types=satellite)]]

To show a map with hybrid and satellite map types (in this order) where the satellite map is preselected:

[[GoogleMap("Street; City; County",zoom=10,size=400x400,types=hybrid:satellite,type=satellite)]]

To show a map with hybrid and satellite map types (in this order) where the hybrid map is preselected:

[[GoogleMap("Street; City; County",zoom=10,size=400x400,types=hybrid:satellite)]]
[[GoogleMap("Street; City; County",zoom=10,size=400x400,types=hybrid:satellite,type=hybrid)]]

Recent Changes in the Release Branch

15265 by rjollos on 2016-02-11 05:29:08
Remove unnecessary svn:mime-type on js and html files

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

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

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

8649 by martin_s on 2010-09-06 12:08:31
Added support for mulit-line wiki processor syntax. Ref: 7628.

Recent Changes in the Develop Branch

ChangeLog macro failed
No node googlemapmacro/dev/0.11 at revision 16184


Author: martin_s