Extension:Semantic Google Maps

Semantic Google Maps is an extension that provides Google Maps functionality to wikis that use the Semantic MediaWiki extension.

What does this extension do?
Semantic Google Maps provides a map interface to the Semantic MediaWiki Geographic coordinate property type, through the following features:

1. Display of coordinates. A parser function, '#semantic_google_map', that displays a Google Map that shows a single point, defined as a set of geographic coordinates.

3. Aggregation of coordinates. An output format for a Semantic MediaWiki query, named 'googlemap', that allows a set of pages that have coordinate data to be displayed together on a Google Map.

3. Insertion of coordinates. A custom Semantic Forms input type, also named 'googlemap'. This input type displays a map with a geocoder in a form to make the insertion of coordinates easy for users.

Download and installation
You can download the Semantic Google Maps code in either one of these two compressed files:


 * semantic_google_maps_0.3.1.tar.gz
 * semantic_google_maps_0.3.1.zip

You can also download the code directly via SVN from the MediaWiki source code repository, at http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/SemanticGoogleMaps/. From a command line, you can call the following:

svn checkout http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/SemanticGoogleMaps/

You must also obtain a Google Maps API key for this wiki, if you don't already have one; a key can easily be obtained here. Note that use of the Google Maps API is free only if your site is accessible to the public; otherwise it costs money - read the Google Maps terms of service for further details.

Once you have downloaded the code, place the 'SemanticGoogleMaps' directory within your MediaWiki 'extensions' directory. Then add the following code to your LocalSettings.php file after the line that installs Semantic MediaWiki (and after the line that installs Semantic Forms, if you use it):

Display a single point
To include a map from within a template:

If a normal page holds:

Template:Location could contain something like:

Has coordinates::

Variables that the semantic_google_map function takes, and their default values, are:

$coordinates='1,1', $zoom = '14', $type = 'G_NORMAL_MAP', $controls = 'GSmallMapControl', $class = 'pmap', $width = '200', $height = '200', $style = ''

To make a large map for a page, for instance, your template could hold the following:

Display multiple points
Note: this functionality requires the very latest Semantic MediaWiki version (SMW 1.2g or higher) to work.

You can set a Semantic MediaWiki #ask query to display its results in a Google Map, by setting "format=googlemap". One of the properties queried and displayed must of type 'Geographic coordinate' for this query to work; this property is what will determine the location of each point on the map. Clicking on each point will display a label holding the name of the page, along with any other queried information; clicking on the page name will bring the user to that page. The zoom level of the map will be the closest one possible that shows all the points.

If you use this format, you can also add two additional parameters to the query: 'width=' and 'height=', representing the width and height of the map. These both default to 400.

Here is an example of an #ask query that uses the 'googlemap' format:

Google Map form input
Use this code in a Semantic Forms form, to include a geocoder in that form:

Coordinates:

Geocoding addresses
You may not want to require users to enter a set of coordinates, but address instead. In that case, you could install and use the Google Geocoder extension to set the property of type Geographic Coordinates automatically. Has coordinates::

If they are already entering an address for that same location as template parameters, these parameters can be reused to avoid duplicate work for users. The code in the template could then look something like this: Has coordinates:: If you wanted to display the location in a map on the page, you could also call something like:

Version
The version history for this extension is:
 * 0.1 - September 2, 2007 - initial version
 * 0.2 - September 5, 2007 - Semantic Forms input changed to use SF's input-type hook
 * 0.3 - July 7, 2008 - overhaul; existing parser function and input type renamed, and #ask query format created
 * 0.3.1 - July 22, 2008 - changed setting of map size to use API instead of CSS style; improved padding around coordinates in query map; language support added for Dutch, French, Galician, Norwegian Bokmål, Slovak and Swedish

Bugs and feature requests
If you have bug reports or requests, please either send them to Yaron Koren, at yaron57 -at- gmail.com, or add them to the Talk page.

Contributing patches to the project
If you found some bug and fixed it, please create a patch by going to the "SemanticGoogleMaps" directory, and typing:

svn diff >descriptivename.patch

Then either send this patch, with a description, to Yaron Koren, or add it on the Talk page.

=Dependencies=
 * Semantic MediaWiki
 * Semantic Forms
 * ParserFunctions

= Sites that use this extension=
 * Placeography - Histories and stories about buildings and land
 * Tech Presentations
 * Verwaltungskooperation - Cooperation in Public Administration
 * Wikimaas - Independent city guide of Maastricht
 * Venicewiki.org The People's Guide to Venice
 * Web Community Wiki

= See also =
 * Extension:Google Maps - non-semantic Google Maps extension
 * Extension:Google Geocoder - extension for converting addresses to geographical coordinates. Uses Google Geocoder service
 * Google Maps widget that uses MediaWiki Widgets extension