Extension:NewMapExtension
From Tetherless World Wiki
Contents |
What does this extension do?
In this extension, we provide a parser function, #map_objects, that will accomplish following tasks:
- Data presentation:
- Display coordinate and the information related to the corresponding coordinate.
- Display information provided in a KML file.
- A Semantic Group Control, a group of checkboxes represent properties of coordinates for user to filter query result, and display the result on the map.
- A number indicate the number of coordinates displayed on the map after filter.
- Navigation:
- Provide a list of coordinates' name(page name), user can click on coordinate's name to adjust the center of the map at that coordinate.
- A search bar to filter the names of coordinates on the list.
In this extension we also provide another parser function, #insert_map, that will display the limited information of coordinate:
- Only the coordinate of location and an info-window contain the information user provide
Download and installation
In order to use this extension, you must obtain a Google Maps API Key for your wiki. Get your key here. Please read Google Map terms and service.
After you get your Google Maps API Key and downloaded code, place the 'GoogleMapTools' directory within your MediaWiki 'extensions' directory. Then add following code to your LocalSetting.php after the line that installs Semantic MediaWiki (and after the line that installs Semantic Forms, if you use it)
$wgGoogleMapsKey = "...enter your Google Maps API key here...";
require_once ("$IP/extensions/GoogleMapTools/Individual_Location.php");
require_once ("$IP/extensions/GoogleMapTools/GoogleMapClick.php");
require_once ("$IP/extensions/GoogleMapTools/GoogleMapMultiObjects.php");
Usage of #map_objects
Display Points and Related Information
This parser function is able to display the coordination on the map, and present the information about the coordinate(picture, properties, etc.) in corresponding coordinate's info-window.
One way user can pass information by input a HTML table: sample syntax:
{{#map_objects:
<table class="smwtable" id="querytable1">
<tr>
<td>133 Sunset Terrace</td>
<td>42.72897,-73.66867</td>
<td>http://map.rpi.edu/index.php/133_Sunset_Terrace</td>
<td>133-S</td>
<td>Service</td>
<td>images/7/72/Eaton2.JPG</td>
</tr>
<tr>
<td>15th Street Parking</td>
<td>42.72856,-73.6779</td>
<td><a href="http://map.rpi.edu/index.php/15th_Street_Parking" class="external free" title="http://map.rpi.edu/index.php/15th_Street_Parking" rel="nofollow">http://map.rpi.edu/index.php/15th_Street_Parking</a></td>
<td>15th.St[P]</td>
<td>Parking</td>
<td></td>
</tr>
}}
Note: This parser function is order sensitive, structure sensitive and first three parameters are required. In other word, table structure is required and the order of sending information to the parser function can't change. However, user does not required to send all information. User can skip any piece of information(not first three) by leave it empty, e.g., <td></td>. The order of parameters are:
- Name of coordinate
- Latitute,Longitute
- Link to the coordinate's page
- Coordinate's name on the map
- any information for semantic group e.g., coordinate's property/service.
- relative link to image
Another way user can pass information to the parser function is use semantic query. A sample syntax:
{{#map_objects:
{{#ask: [[Category:Location]] | ?Has LatLong | ?Has URL | ?Has short name
| ?Has service |?FOAF:page |limit=200|link=none}}
}}
Important: First three parameters (page name, Latitue Longitude, and URL to the page)are required in order to dipslay coordinates properly on map. Where LatLong is latitute and longitute of a coordinate in this format: "lat,long".The order of paramter is same as first way.
If user would like to provide a shorter name or any string to label the marker on the map, user can pass this information in fourth parameter. User can skip this parameter by leave it empty, e.g.:
{{#map_objects:
{{#ask: [[Category:Location]] | ?Has LatLong | ?Has URL | | ?Has service |?FOAF:page |limit=200|link=none}}
}}
The fifth parameter (?Has service in this case) is where user can pass information about coordinate for generate Semantic Group, skip it if you want (as above example).
The sixth parameter (?FOAF:page in this case, should be a relative link) is where user can provide picture of coordinate and only the picture of the coordinate to be displayed on coordinate info-window, skip it if necessary.
Display Points or Lines use KML
User can also pass links of KML files to display KML files' information on google map.
sample syntax for passing one KML file:
{{#map_objects:
{{#ask: [[Category:Location]] | ?Has LatLong | ?Has URL | | ?Has service |?FOAF:page |limit=200|link=none}}
|Route;http://shuttles.rpi.edu/data/route.kml
}}
In this example, "Route;http://shuttles.rpi.edu/data/route.kml" is where user pass the KML file. Where "Route" is a semantic group controller name of the information provided in this KML file. And "http://shuttles.rpi.edu/data/route.kml" is the link to the KML file. Important Note: notice that "Route" and "http://shuttles.rpi.edu/data/route.kml" is separated by ";"
sample syntax for passing more than one KML file:
{{#map_objects:
{{#ask: [[Category:Location]] | ?Has LatLong | ?Has URL '''| |''' ?Has service |?FOAF:page |limit=200|link=none}}
|Route;http://shuttles.rpi.edu/data/route.kml Stop;http://shuttles.rpi.edu/data/stops.kml building;http://shuttles.rpi.edu/data/building.kml
}}
The syntax for passing multiple KML file is almost same as passing only one KML file, but using space to separate them.
Note: to present KML information on this map, we need at least one coordinate on the map provided by first semantic query
see more information on KML [KML Documentation Introduction http://code.google.com/apis/kml/documentation/]
Change Dimensions and Controls of Map
The default parameters of the map is set as follows: width= - defaults to 800 height= - defaults to 600 zoom= - defaults to 16 map type= - defaults to G_HYBRID_MAP map control= - defaults to GSmallMapControl
You can change any of above parameter. The order of these parameters are: zoom level map type map control css class attribute width height
Sample syntax:
{{#map_objects:
{{#ask: [[Category:Location]] | ?Has LatLong | ?Has URL '''| |''' ?Has service |?FOAF:page |limit=200|link=none}}
|Route;http://shuttles.rpi.edu/data/route.kml
|17
|G_HYBRID_MAP
|GSmallMapControl
|pmap
|800
|600
}}
Note: dimension and control of map start at third parameter.
Usage of #insert_map
As described, this parser function will provide the limited information of a coordinate on map.
A sample syntax:
{{#insert_map: 17.3,17.8
|2
|G_HYBRID_MAP
|GLargeMapControl
|class1
|800
|600
|border: thin dotted #00FF00
|<b>This is an example</b>
|Empire Building
}}
The order of these parameters are:
- zoom level
- map type
- map control
- css class attribute
- width
- height
- css style attribute
- a html formated string to be displayed on info-window
- marker's label name
Bugs, new feature request and contact information
If you found any bug encounters in current version of extension, or you would like to request new feature, or any feedback are welcome. My email is zhengj3-at-rpi.edu
