Extension:Semantic Google Maps

This is a semantic approach to including maps in MediaWiki. Semantics add great value to MediaWiki as it drastically improves both human and machine usability and readability of information.

=What does this extension do?= This extension provides a map-interface to the Geographic Coordinates attribute-type of Semantic Mediawiki.

1. Display of coordinates: The extension provides a parser function that can be used in semantic- templates. It adds a little map on pages that use these templates. The parser-function uses the semantic property of type 'Geographic Coordinates' for centering the map and displaying a marker.

2. Insertion of coordinates: On the input side, the extension provides a Semantic Forms hack that adds an extra input type. The input type shows a little map with a geocoder in your forms to make the insertion of coordinates easier for users.

=Background=

What are semantics?
You can find more information about semantics at ontoworld.org.

Other Map Extensions
Most other extensions that integrate (Google) maps into MediaWiki create a tag. By including this tag, a map is included in a page. The geographic coordinates are given within the tag and are only used for including the map. Additionally functionality like creating GeoRSS feeds works by searching articles in a specific category, looking for the map-tag within articles and extracting geographic coordinates from that tag.

An example of this kind of approach is the excellent Extension:GeoRSS. There are a few disadvantages to this approach though. The tag in this extension is not available in the source, the map is always included in the same way, the map can not be included in the template, the coordinates are not easily available to other extensions, the coordinates are not visible in the page, search machines have no way of indexing the locations.

Semantic Map Extension
The semantic approach does not introduce yet another tag for including a map. It produces as little extra code as possible and leans heavily upon Semantic MediaWiki and Semantic Forms. Semantic MediaWiki offers a way of intelligently storing and displaying geographic coordinates. Semantic Forms offers a user friendly way of adding and editing semantically stored data.

Semantic Google Maps provides a way of including a map in any page that includes semantic coordinates. This map is defined in the template page of the semantic template that the coordinates are part of. Currently this can only be done by a parser extension, because parser extensions can take template-variables as input.

On the other hand Semantic Google Maps provides a way of adding and editing coordinates to an article by simply clicking in a map. This is done by defining an extra input-type for the Semantic Forms extension that displays a map that feeds the coordinates to the form-field when it is clicked upon.

=Installation= Copy these two files to your extensions directory:


 * ParserCoordinates.php
 * InsertMap.php

Copy this file to the extensions/SemanticForms/includes/ directory:


 * SF_FormPrinter.inc

Add the following code to your LocalSettings.php file:

$wgGoogleMapsKey = "ABQIAAAAmbYSvchg-WUKZ1VciMUQehQX8X62KH66Ufsfzx";

require_once( "$IP/extensions/ParserCoordinates.php" );
 * 1) parser function coordinates

require_once( "$IP/extensions/InsertMap.php" );
 * 1) parser function insert_map

(change the Google Maps api key to your own)

=Usage=

Insert Map
To include a map in a semantic template:

If a normal page holds:

Template:Location holds:

6 is the zoomlevel. Variables the insert_map function takes and their default values are:

$lat = '1', $lon = '1', $zoom = '2', $type = 'G_HYBRID_MAP', $controls = 'GSmallMapControl', $class = 'pmap', $width = , $height = , $style = ''

Insert Coordinates Form Map
In the semantic form a little map is inserted that displays a map.

Use this code in the Semantic Forms form, to call the map in the form:

Coordinates:

=Dependencies=
 * Semantic Mediawiki
 * Semantic Forms
 * Parser functions

= Sites that use this extension=
 * Wikimaas - Independent city guide of Maastricht

= Todo =
 * Rewrite function wfConvertCoordParserFunction_Render in ParserCoordinates.php to also work with 5° 4' 6" E format and not only with 5.15° E format.