Working With MediaWiki
#display_map would be:
{{#display_map:Nairobi National Park~Nairobi National Park~Kenya’s first national park.~Green marker.png |zoom=11 |width=475 |height=350}}
Either call would produce the output seen in Figure 18.3. This image shows the map if the marker is clicked on, and then hovered over — the “title” field serves as both the title of the caption, and the hover text.
Figure 18.3 Map created using #display_map, from the Maps extension
In addition, Maps defines the following functions (all available as both tags and parser functions), which are helpful when dealing with geographical data:
coordinates — converts coordinates from one format to another (such as converting from degrees-minutes-seconds to a decimal number)
distance — converts a distance from one unit to another (such as miles to kilometers)
finddestination — displays the coordinates of a location, given an initial location, a bearing (an angle) and a distance
geocode — displays the coordinates of a location, given an address or place name
geodistance — displays the distance between two coordinates or place names
Semantic Maps
The Semantic Maps extension requires the extensions Semantic MediaWiki and Maps (it also requires Validator, which is also required by those other extensions). It defines a new SMW property type,“Geographic coordinate”, that is used for coordinates. It provides a way to display coordinate data from multiple pages on one map, through various query formats. And it also lets you use a map to enter coordinates in a Semantic Forms-based form.
Here’s an example of a simple query that displays a map:
{{#ask:[[Category:Parks]] |?Has coordinates |format=googlemaps}}
In order for this query to work, one or more pages in the category “Parks” need to have the property “Has coordinates” set for them, with valid coordinates; and the property “Has coordinates” needs to be defined as having type “Geographic coordinate”.
Queries with Semantic Maps can take in most of the same additional parameters that the display_map function from Maps can. Its set of allowed parameters is:
center
/
centre
,
width
,
height
,
zoom
,
geoservice
,
template
,
icon
,
forceshow
and
showtitle
. The last four parameters are new to Semantic Maps. The “template” parameter lets you set the layout of the caption for each point; see here for how it can be used. The “icon” parameter sets the icon/marker image to be used for the points. The “forceshow” parameter shows a map even if there are no results to display; by default it’s set to “yes”. And the “showtitle” parameter dictates whether page titles are shown for each point on the map; by default it’s set to “yes” as well.
There are various other parameters, that are specific to each mapping format.
Here’s an example of a more complicated query:
{{#ask: [[Category:Locations]]
| ?Has coordinates
| ?Has location type
| ?Located in
| format=map
| template=Location Popup
| showtitle=no
| icon=Blue_marker.png
}}
This query uses a template, “Location Popup”, that formats the set of values for each point — there are three values for each point, but the page title is not one of them, because “showtitle” is set to “no” as well. And every point is shown with a custom icon — the uploaded image “Blue marker.png”.
The query formats that Semantic Maps supports are “maps”, “googlemaps”, “openlayers” and “kml”. The first three are hopefully self-explanatory; they are identical to the “service” parameter values for the Maps extension.The last one, “kml”, exports the data in KML (Keyhole Markup Language), a standard file format for coordinate data.
Map form inputs
The other very useful feature of Semantic Maps is that it provides form inputs for map-based entry of coordinates within Semantic Forms forms. Since it’s usually unlikely that users will know the geographical coordinates of a place, a map lets users easily find the point, and automatically determine the coordinates.
Figure 18.4 shows how a map form input looks. Here, the user has entered “causeway bay, hong kong” into the address lookup field, and clicked on “Look up coordinates”. The map now shows a location on the map, and the coordinates field (which is the field whose value actually ends up on the resulting page) is set to match that location. Assuming the real location the user is looking for is somewhere around there, the user now has
Weitere Kostenlose Bücher