Maps in Mediawiki: Difference between revisions
Ttenbergen (talk | contribs) |
Ttenbergen (talk | contribs) |
||
Line 8: | Line 8: | ||
== Maps via Cargo Displayformat == | == Maps via Cargo Displayformat == | ||
not working right now <!-- | |||
Cargo can format its query results in some unexpected ways, and one of them is [https://www.mediawiki.org/wiki/Extension:Cargo/Display_formats#Maps as a map]. If the data is already in Cargo then this method draws a map with just one line of code, e.g. | Cargo can format its query results in some unexpected ways, and one of them is [https://www.mediawiki.org/wiki/Extension:Cargo/Display_formats#Maps as a map]. If the data is already in Cargo then this method draws a map with just one line of code, e.g. | ||
<nowiki>{</nowiki>{#cargo_query: table=Place | fields = Name, Description, Coordinates | format = googlemaps| width = 400| height = 200}} | <nowiki>{</nowiki>{#cargo_query: table=Place | fields = Name, Description, Coordinates | format = googlemaps| width = 400| height = 200}} | ||
Line 16: | Line 17: | ||
{{#cargo_query: table=Place | fields = Name, Description, Coordinates | format = googlemaps| width = 400| height = 200}} | {{#cargo_query: table=Place | fields = Name, Description, Coordinates | format = googlemaps| width = 400| height = 200}} | ||
* after maps query | * after maps query | ||
}} | |||
--> | |||
== Maps via the Maps extension == | == Maps via the Maps extension == |
Revision as of 17:47, 2024 August 14
Mediawiki can be used with the Mediawiki Extension Maps to display maps with markers based on coordinates. These coordinates can be provided explicitly or through data, such as through Mediawiki Extension Cargo.
Maps via Cargo Displayformat
not working right now
Maps via the Maps extension
Mediawiki Extension Maps is a more flexible way to display maps. It allows adding shapes like lines, rectangles and circles and can use different layers such as satellite photography and openstreetmaps. It can still be used with Cargo data by writing an inline Cargo query to provide coordinates for targets or shapes. It can also take names of locations and addresses as input instead of coordinates, which makes it more flexible in what data can drive it. For example, the following code will list all locations in table place and then draw a line between two of them; the layers button in the top right corner will switch between map view and satellite image view.
{{#display_map: {{#cargo_query: table=Place |fields = CONCAT(Coordinates__full, '~', Name ) |format=list |delimiter=; |no html }} |lines= {{#cargo_query: table=Place |fields = Coordinates__full |where=Name="North Forge" |format=list |delimiter=; |no html }}:{{#cargo_query: table=Place |fields = Coordinates__full |where=Name="WRC" |format=list |delimiter=; |no html }} |copycoords=yes |resizable=on |layers=OpenStreetMap,Esri.WorldImagery |height=200 }}
Encoding locations in a cargo table to use them in queries
Storing locations in a Cargo table allows data driven maps. This wiki contains Template:Place which defines Cargo Table Place. This table has a field "Coordinates" in a data type meant for map coordinates. Coordinates for locations can be obtained from Google Maps by right-clicking on an area and then clicking on the coordinates.
Here are some template calls to store test data used above:
{{Place| Name=North Forge | Description=A makerspace | Coordinates = 49.89959808249238, -97.14224677575343 }}
{{Place| Name=WRC | Description=A rowing club | Coordinates = 49.88086121609553, -97.13063599481808 }}
Related articles
Related articles: |