Extension:Google Maps/Installation

Note: Version works with MediaWiki 1.5 and up. It is recommended over all previous versions. Note, however, the Editor's Map will only be available if you're using MediaWiki 1.6 or greater.

Basic Installation in Three Easy Steps
1. Go sign up for a Google Maps API key from.

2. Download this file, and unzip it into your "extensions" directory: /GoogleMaps-.zip

It should create a "GoogleMaps" folder with a few files.

3. Add this to the end of LocalSettings.php:

$wgGoogleMapsKey = "your key from step 1 goes here"; require_once( "extensions/GoogleMaps/GoogleMaps.php" );

If all went well, you should be good to go! See Extension:Google Maps/Usage for how to test it out.

From 0.6, 0.7, or 0.8
Just delete your extensions/GoogleMaps/ directory and then get a fresh copy of http://emiller.info/maps/GoogleMaps-.zip, and unzip it into your "extensions" folder.

From 0.5 or 0.4
You need to delete the file extensions/GoogleMaps.php, and update LocalSettings.php to have this:

require_once( "extensions/ GoogleMaps/ GoogleMaps.php" );

Then unzip /GoogleMaps-.zip inside your extensions directory, and you should be good to go.

From earlier versions
See Extension:Google Maps/Old versions first.

Setup
Of course, you might be itching to try out some of the basic/advanced features: default co-ordinates, colored paths, custom markers etc. The rest of this page will explain how to turn on these features.

Changing the default co-ordinates (and other things)
Odds are you don't want your maps to be centered in Williamstown, Massachusetts by default. You can change the default co-ordinates by adding this to LocalSettings.php:

$wgGoogleMapsDefaults = array( "lat" => 13.3801841, "lon" => -45.8103148 );

Where of course you insert your own co-ordinates. Use the Editor's Map to find the position you want.

You can also change the other default map attributes with $wgGoogleMapsDefaults. Just add the appropriate key/value pairs. Some useful ones:


 * zoom: The default zoom level, between 1 (far out) and 18 (close up)
 * width: The default width of maps in pixels
 * height: The default height of maps in pixels
 * icon: The default URL of the map's icons.

You can actually override any map tag attributes. See Extension:Google Maps/Syntax for details. In addition, these keys will change the behavior of the editor's map:


 * units (unit of measure for calculating distances. Legal values are meters (default) and miles)
 * version (version of the Google Maps API to use; defaults to 2.85)
 * color (the default color of paths in RGB hex format, e.g. "#000000")
 * precision (number of decimal places to use with co-ordinates; defaults to 6)

Changing the default settings on a per-page basis
Now you might be thinking, it sure would be useful to set different default co-ordinates for different pages; say, maps created on the "New York City" page would be centered on the Big Apple while maps on the "Boston" page would automatically focus on Massachusetts. Well, now you can do that! Just specify an intermediate key with the page name you want to apply the values to. For example:

$wgGoogleMapsDefaults = array(                "Boston" => array( "lat" => 42.358333, "lon" => -71.060278 ),                "New York City" => array( "lat" => "40.714167", "lon" => -74.006389 ),                "lat" => 13.8442, "lon" => -45.1831); # these apply to all other pages

You can specify any map attribute this way.

Colored paths
''Good news! The MediaWiki folks accepted my patch, so if you're running MediaWiki 1.9 and using Google Maps Extension 0.7.5 or later, colored paths should work out-of-the-box. Otherwise, read on.''

This part is a small pain in the neck. Internet Explorer won't let you draw paths unless there's a special tag at the very beginning of the page. Unfortunately, this means you'll need to muck around with other files in your MediaWiki installation. But don't worry, it'll only take a minute. Just add the stuff in red you see below.

1. Change line 982-ish in includes/OutputPage.php from this:

$ret .= "\n";

To this:

$ret .= "\n";

2. Change line 54-ish in skins/MonoBook.php (or YourSkinName.php if you use another default skin) from this:

text('lang') ?>" lang="text('lang') ?>" dir="text('dir') ?>">

To this:

text('lang') ?>" lang="text('lang') ?>" dir="text('dir') ?>">

3. Now you need to tell the extension that paths are working. In LocalSettings.php (anywhere, but close to your other extension configuration is a good idea), add this line:

$wgGoogleMapsEnablePaths = true;

That's it! Now you can draw on your maps to heart's content.

Multiple API keys
In the past, if your wiki was accessible from multiple URLs, then you had to choose only one of them to work with Google Maps Extension. No more! Just add an array called $wgGoogleMapsKeys to LocalSettings.php with domains as the keys and your Google Maps API key as the value, e.g.:

$wgGoogleMapsKeys = array( "wiki.mycoolsite.com" => "ABQIAAAA5nNsCplt4ROF-lZxSn8x7BTr7dBAVb7q3Yj",                           "www.mycoolsite.com/wiki" => "ABQIA32j2islt4ROF-lZxSn8x7dssjdfsoaOE323ssa" );

The extension will use the appropriate one based on where it receives requests from. NOTE however that MediaWiki's caching mechanism may interfere with this. If you experience problems you can turn off MediaWiki's cache, but you will suffer a performance hit. To disable the cache, put this in LocalSettings.php:

$wgEnableParserCache = false;

Disabling the search box
(0.7.5 and up) Unfortunately, the business search and address search don't work everywhere, mainly just the U.S., Canada, Japan, and a few countries in Western Europe. If you want to disable these search features on your wiki, just open up LocalSettings.php and set the values of "geocoder" and "localsearch" in the $wgGoogleMapsDefaults variable to false, like this:

$wgGoogleMapsDefaults = array( "geocoder" => false, "localsearch" => false );

If you want to disable local (business) searches but keep the geo-coder, you would use this:

$wgGoogleMapsDefaults = array( "geocoder" => true, "localsearch" => false );

You can also disable or enable these features on a per-page basis, as described above.

Disabling the Editor's Map
(0.7.5 and up) Some people think the Editor's Map gets in the way. To disable it altogether, just add this to LocalSettings.php:

$wgGoogleMapsDisableEditorsMap = true; 'Italic text'

Debugging
Problems? First check the Extension:Google Maps/Compatibility page to see whethere it's supposed to work on your system.

While you're tinkering with settings, you may need to try a couple tricks. One problem is that a new map will be generated only when you save a change to the page that contains the. If you want to test changes to the server just by hitting "Reload" in your browser, add "?action=purge" to the end of the URL. That will ensure that the entire page is generated fresh every time you load it, rather than every time you save it. Alternatively, you can switch off server-side caching altogether by adding this line to LocalSettings.php:

$wgEnableParserCache = false;

If you're still having trouble, leave a note on the Extension talk:Google Maps page.