Jump to content

Maps in Mediawiki: Difference between revisions

From Squirrel's Lair
Ttenbergen (talk | contribs)
m Ttenbergen moved page Maps to Maps in Mediawiki without leaving a redirect
Ttenbergen (talk | contribs)
mNo edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[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]].
{{TidBit
|shortDescription=Displaying Maps in Mediawiki
|skillSet=Mediawiki
|featured=Yes
}}
 
[[Mediawiki]] can be used 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 ==
== 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 = leaflet| width = 400| height = 200}}
  <nowiki>{</nowiki>{#cargo_query: table=Place | fields = Name, Description, Coordinates | format = googlemaps| width = 400| height = 200}}
see [[Special:CargoTables/Place]] for contents of that table
A disadvantage is that it won't display in preview mode, only once you save, which can slow troubleshooting. This method is also limited in how much it can annotate the maps.
A disadvantage is that it won't display in preview mode, only once you save, which can slow troubleshooting. This method is also limited in how much it can annotate the maps.


{{#cargo_query: table=Place | fields = Name, Description, Coordinates | format = leaflet| width = 400| height = 200}}
* before maps query
{{#cargo_query: table=Place | fields = Name, Description, Coordinates | format = googlemaps| width = 400| height = 200}}
* after maps query
}}
-->


== Maps via the Maps extension ==
== Maps via the [[Mediawiki Extension Maps]] ==
[[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.
[[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.  
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.  
Line 38: Line 50:
  <nowiki>{</nowiki>{Place| Name=North Forge | Description=[https://northforge.ca/ A makerspace] | Coordinates = 49.89959808249238, -97.14224677575343 }} {{Place| Name=North Forge | Description=[https://northforge.ca/ A makerspace] | Coordinates = 49.89959808249238, -97.14224677575343 }}
  <nowiki>{</nowiki>{Place| Name=North Forge | Description=[https://northforge.ca/ A makerspace] | Coordinates = 49.89959808249238, -97.14224677575343 }} {{Place| Name=North Forge | Description=[https://northforge.ca/ A makerspace] | Coordinates = 49.89959808249238, -97.14224677575343 }}
  <nowiki>{</nowiki>{Place| Name=WRC | Description=[https://winnipegrowingclub.ca/ A rowing club] | Coordinates = 49.88086121609553, -97.13063599481808 }} {{Place| Name=WRC | Description=[https://winnipegrowingclub.ca/ A rowing club] | Coordinates = 49.88086121609553, -97.13063599481808 }}
  <nowiki>{</nowiki>{Place| Name=WRC | Description=[https://winnipegrowingclub.ca/ A rowing club] | Coordinates = 49.88086121609553, -97.13063599481808 }} {{Place| Name=WRC | Description=[https://winnipegrowingclub.ca/ A rowing club] | Coordinates = 49.88086121609553, -97.13063599481808 }}
{{WhatLinksHere|}}

Latest revision as of 17:48, 2024 August 14


  • Cargo:


  • Categories:
  • Default form


Mediawiki can be used 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 Mediawiki Extension Maps

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
}}
Loading map...

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 }} 
  • Cargo


{{Place| Name=WRC | Description=A rowing club | Coordinates = 49.88086121609553, -97.13063599481808 }} 
  • Cargo


Related articles

Related articles: