Extension:Google Maps/Syntax

From MediaWiki.org

Jump to: navigation, search

Introduction - Installation - Editor's Map - Syntax - Compatibility - Languages - Developers - Talk

         

Manual on MediaWiki Extensions
List of MediaWiki Extensions
Crystal Clear action run.png
Google Maps Extension

Release status: beta

Google Maps Extension Type Selector.jpg
Implementation  Tag
Description Easily create maps populated with wiki-fied place markers.
Author(s)  Evan Miller
Last Version  0.9.4 (2009-01-27)
MediaWiki  1.5 and up
License GPL
Download Download snapshot

Subversion [Help]
Browse source code
zip file tar ball (instructions)


In many cases you can get by with the Editor's Map, but understanding the underlying syntax will unlock a few extra features for you.

Contents

[edit] Tag Attributes

This extension defines a <googlemap> tag. Legal attributes are:

  • width (in pixels; defaults to 450)
  • height (in pixels; defaults to 300)
  • lat (the center latitude on the map, defaults to my old dorm room :-)
  • lon (the center longitude on the map)
  • zoom (the zoom level; 0 is the furthest away, 17 is the closest in)
  • type (legal values are normal (or, equivalently, map), terrain (new in 0.9.0), hybrid, and satellite; defaults to hybrid)
  • controls (small creates +/- zoom buttons, medium has zoom buttons and pan buttons, large has pan buttons with a sliding scale for zoom, and none has no buttons)
  • selector (show the map/hybrid/satellite selector? Legal values are yes (default) and no.)
  • scale (show the distance scale? Legal values are yes and no (default).)
  • overview (show the inset navigation map? Legal values are yes and no (default).)
  • icons (URL template for custom markers, with "{label}" where the name of the icon will be inserted; defaults to "http://maps.google.com/mapfiles/marker{label}.png")
  • icon (URL for markers without an icon specified; defaults to http://maps.google.com/mapfiles/marker.png)
  • doubleclick new in 0.7.6 (what to do when the user double-clicks? legal values are recenter (default) and zoom)
  • zoomstyle new in 0.7.6 (legal values are fast (default) and smooth, also known as continuous zooming; only works in some browsers)
  • stroke new in 0.8.0 (width of paths, in pixels)
  • version new in 0.9.0 (specifies syntax version, see below; legal values are "0" (default) and "0.9")
  • scrollwheel new in 0.9.0 (define scroll wheel behavior; nothing (default) or zoom)

All attributes are optional.

[edit] A note about icons

You can host your own collection of icons on your server, but note that they'll have the same anchor points as Google's default icon. Check out Mapki's collection of icon images for a bunch of icons you can use. To use your icons, add an icon attribute to your googlemap-tags like this

<googlemap lat="42.711618" lon="-73.205112" zoom="2" controls="small" 
icon="http://myserver.com/standardmarker.png" 
icons="http://myserver.com/markers/marker{label}.png">

[edit] Using <googlemap> in a template

If you would like to put a map inside a template, then you will need to use a slightly different syntax to get the variables to work properly.

Following is an example for including a map without markers.

BAD:

<googlemap lat="{{{1}}}" lon="{{{2}}}">

GOOD:

{{#tag:googlemap|lat={{{1}}} lon={{{2}}}}}

This #tag technique only works with MediaWiki 1.12 and later.

if the above does not work, try


{{#tag:googlemap
|lat={{{1}}}
|lon={{{2}}}
}}

[edit] KML export

Beginning with 0.9.0, a new tag called googlemapkml is defined. This will export all of the maps on the current page to a KML file. The contents of the tag are the contents of the link, e.g.

<googlemapkml>Download KML</googlemapkml>

To export the KML from another article, just use the "article" attribute, e.g.

<googlemapkml article="Main Page">Download KML</googlemapkml>

[edit] KML import - export

It is possible to merge the maps of some other articles within a new article’s map, but you must use the full url of GoogleMapsKML.

<googlemap>
http://your.wiki.url/index.php?title=Special:GoogleMapsKML&article=a_article
http://your.wiki.url/index.php?title=Special:GoogleMapsKML&article=another_article
...
</googlemap>

[edit] Map syntax version "0" (default)

This section describes the "old syntax", which is enabled by default. To force its use, set version="0" in the map attributes.

[edit] Markers

In the content of the tag, you can define one marker per line. Each line may or may not start with an icon name in parentheses; unless you set the "icons" attribute, legal icon names are the upper-case letters of the alphabet. The line should then have the latitude, then a comma, optionally a space, then the longitude, then a comma, then a label for the point. The label can include wiki mark-up (and commas). These are all legal:

<googlemap lat="42.711618" lon="-73.205112" zoom="2" controls="small">
42.711618,-73.205112,the fabulous, famous [[Sawyer Library]]
42.711618, -73.205112, the fabulous, famous [[Sawyer Library]]
(S) 42.711618, -73.205112, the fabulous, famous [[Sawyer Library]]
</googlemap>

[edit] Paths

This feature must first be enabled on your wiki; see Extension:Google Maps/Installation#Colored paths

To connect multiple points with a colored path, prefix them with a line that begins with the color in RGB hex format., e.g.

#330000
42.711618,-73.205112
42.714779,-73.204544

That will connect the two points with a colored line. Any points not on a line should appear before all points on lines. For example:

42.711618, -73.25112, this point is not on a line
43.224024, -70.28301, neither is this one
#770077
42.202452, -72.83101, this is on a line of color #77077
45.214425, -72.48114, so is this
#668800
42.201324, -70.95811, this starts a second line
43.404142, -73.44514, this is also on the second line

Any text on the same line as, but appearing after, the color specification will be ignored.

You'll probably want to use the Extension:Google Maps/Editor's Map to generate this syntax.

[edit] Areas

New in 0.8

Areas are enclosed paths with a colored filling. The syntax is just like a path, except that the interior color should be specified in parentheses after the path color, like this:

#770077 (#668800)

[edit] Tabs

New in 0.7

A feature new to 0.7 are tabbed info balloons. Each tab should have a plain-text title surrounded by inward-leaning slashes (like /this\) followed by a caption that can include wiki mark-up. Tabs will be attached to the previous marker. Example:

 45.214425, -72.48114
 /Info\       This is where Ulysses Grant is buried
 /Directions\ [http://maps.google.com Click here] to get driving directions

That will create a point whose info balloon has two tabs. Note that you can put as much or as little space as you'd like between the title and the caption to make the syntax more readable.

If a point has a regular caption and tabbed captions, clicking the point will only show the tabbed captions.

[edit] Map syntax version "0.9"

Starting with release 0.9.0, a new map syntax is available. It differs only slightly from version "0". To use the new syntax, you will need to set version="0.9" in the map attributes (the Editor's Map will do this for you). Benefits include:

  • Multiline captions
  • Specify opacity
  • Titles that appear on mouse-over

The new syntax is described below.

[edit] KML import

Before you specify any markers, you can add URLs that point to KML files. Each URL should be on its own line, e.g.

<googlemap>
http://some.url/
http://other.url/
...
</googlemap>

These files will be dynamically imported into the map each time the map is loaded.

[edit] Markers and Tabs

After KML files come a list of markers. Markers can be specified in several ways:

42.711618, -73.205112

No caption, just a point.

(S) 42.711618, -73.205112

A marker labeled "S".

42.711618, -73.205112, Sawyer Library

A title but no caption. The title can NOT contain wiki markup. It is displayed when a user mouses over the marker.

42.711618, -73.205112, Sawyer Library
[[Sawyer Library]], built in 1977

Title plus a caption. The caption appears when a user clicks on the marker. A caption can span multiple lines. However, the title is still optional, so this is okay too:

42.711618, -73.205112
[[Sawyer Library]], built in 1977

Finally, you can also specify tabs. A tab's title should appear between inward facing slashes(/ and \). The content of a tab should be on a new line and can span multiple lines, just like captions.

latitude, longitude, title
/tab1\
caption1
/tab2\
caption2
...

[edit] Paths and Areas

The path syntax changed slightly in 0.9.0. As before, you can connect multiple points by preceding them with a color specification. However, the color specification must now include opacity and stroke information, e.g.

6#FF330000

The 6 means that the path will be 6 pixels wide. The first two hex digits specify the opacity from #00 (transparent) to #FF (opaque). The final 6 hex digits are a "web color", i.e. #RRGGBB. In the example above the opacity is #FF and the color is #330000.

Similarly for areas, the interior color should be 8 digits instead of 6; the first two digits define the opacity, e.g.

6#770077 (#BB668800)

Google Maps Extension for MediaWiki

Introduction - Installation - Editor's Map - Syntax - Compatibility - Languages - Developers - Talk - Versions