Leaflet SMW queries: Difference between revisions
(Created page with "Maps shown with the Leaflet result format can be customized using various parameters. Example demonstrating usage of the Leaflet-only <code>geojson</code> parameter: ; Syntax...") |
mNo edit summary |
||
Line 1: | Line 1: | ||
Maps adds leaflet result format as part of its [[Semantic MediaWiki|integration with Semantic MediaWiki]]. This result format can be used to visualize queried data onto a map. | |||
== Syntax == | |||
Maps shown with the Leaflet result format can be customized using various parameters. Example demonstrating usage of the Leaflet-only <code>geojson</code> parameter: | Maps shown with the Leaflet result format can be customized using various parameters. Example demonstrating usage of the Leaflet-only <code>geojson</code> parameter: | ||
<pre> | <pre> | ||
{{#ask: [[ | {{#ask: [[Coordinates::+]] | ||
| format=leaflet | | format=leaflet | ||
| geojson=Berlin | | geojson=Berlin | ||
Line 14: | Line 17: | ||
; Result | ; Result | ||
{{#ask: [[ | {{#ask: [[Coordinates::+]] | ||
| format=leaflet | | format=leaflet | ||
| geojson=Berlin | | geojson=Berlin | ||
Line 38: | Line 41: | ||
| format=leaflet | | format=leaflet | ||
| ?Has coordinates | | ?Has coordinates | ||
| ajaxquery = [[ | | ajaxquery = [[Coordinates::+]] | ||
| ajaxcoordproperty = Has coordinates | | ajaxcoordproperty = Has coordinates | ||
| zoom=8 | | zoom=8 | ||
Line 48: | Line 51: | ||
| format=leaflet | | format=leaflet | ||
| ?Has coordinates | | ?Has coordinates | ||
| ajaxquery = [[ | | ajaxquery = [[Coordinates::+]] | ||
| ajaxcoordproperty = Has coordinates | | ajaxcoordproperty = Has coordinates | ||
| zoom=8 | | zoom=8 | ||
Line 59: | Line 62: | ||
{{#ask: [[Category:City]] | {{#ask: [[Category:City]] | ||
| format=leaflet | | format=leaflet | ||
| ? | | ?Coordinates | ||
| cluster=on | | cluster=on | ||
}} | }} | ||
Line 66: | Line 69: | ||
{{#ask: [[Category:City]] | {{#ask: [[Category:City]] | ||
| format=leaflet | | format=leaflet | ||
| ? | | ?Coordinates | ||
| cluster=on | | cluster=on | ||
}} | }} | ||
Line 77: | Line 80: | ||
{{#ask: [[Category:Locations]] | {{#ask: [[Category:Locations]] | ||
| format=leaflet | | format=leaflet | ||
| ? | | ?Coordinates | ||
| template=Google Maps Link | | template=Google Maps Link | ||
}} | }} | ||
Line 84: | Line 87: | ||
{{#ask: [[Category:Locations]] | {{#ask: [[Category:Locations]] | ||
| format=leaflet | | format=leaflet | ||
| ? | | ?Coordinates | ||
| template=Google Maps Link | | template=Google Maps Link | ||
}} | }} | ||
Line 95: | Line 98: | ||
{{#ask:[[Category:Locations]] | {{#ask:[[Category:Locations]] | ||
| format=leaflet | | format=leaflet | ||
| ? | | ?Coordinates | ||
| ? | | ?Location type | ||
| ?Located in | | ?Located in | ||
| template=Location Popup | | template=Location Popup | ||
Line 105: | Line 108: | ||
{{#ask:[[Category:Locations]] | {{#ask:[[Category:Locations]] | ||
| format=leaflet | | format=leaflet | ||
| ? | | ?Coordinates | ||
| ? | | ?Location type | ||
| ?Located in | | ?Located in | ||
| template=Location Popup | | template=Location Popup | ||
| showtitle=off | | showtitle=off | ||
}} | }} |
Revision as of 16:24, 8 May 2020
Maps adds leaflet result format as part of its integration with Semantic MediaWiki. This result format can be used to visualize queried data onto a map.
Syntax
Maps shown with the Leaflet result format can be customized using various parameters. Example demonstrating usage of the Leaflet-only geojson
parameter:
{{#ask: [[Coordinates::+]] | format=leaflet | geojson=Berlin | zoom=7 | center=Berlin | ?Has coordinates | ?Has area }}
- Result
Parameters
⧼validator-describe-header-parameter⧽ | ⧼validator-describe-header-aliases⧽ | ⧼validator-describe-header-type⧽ | ⧼validator-describe-header-default⧽ | ⧼validator-describe-header-description⧽ |
---|---|---|---|---|
width | - | ⧼validator-type-dimension⧽ | auto | Allows setting the width of the map. By default pixels will be assumed as unit, but you can explicitly specify one of these units: px, ex, em, %. |
height | - | ⧼validator-type-dimension⧽ | 350 | Allows setting the height of the map. By default pixels will be assumed as unit, but you can explicitly specify one of these units: px, ex, em. |
centre | center | ⧼validator-type-string⧽ | no | The location on which the map should be centered |
title | - | ⧼validator-type-string⧽ | ⧼validator-describe-empty⧽ | Allows setting text that will be displayed in the pop-ups of all markers that do not have a specific title.
When used together with label, the title will be bold and underlined. |
label | text | ⧼validator-type-string⧽ | ⧼validator-describe-empty⧽ | Allows setting text that will be displayed in the pop-ups of all markers that do not have a specific label. |
icon | - | ⧼validator-type-string⧽ | ⧼validator-describe-empty⧽ | Allows setting the icon used for all markers. |
lines | - | List of lines | ⧼validator-describe-empty⧽ | Lines to display |
polygons | - | List of geographical polygons | ⧼validator-describe-empty⧽ | Polygons to display |
circles | - | List of circles | ⧼validator-describe-empty⧽ | Circles to display |
rectangles | - | List of rectangles | ⧼validator-describe-empty⧽ | Rectangles to display |
maxzoom | - | ⧼validator-type-integer⧽ | no | The maximum zoom level |
minzoom | - | ⧼validator-type-integer⧽ | no | The minimum zoom level |
copycoords | - | ⧼validator-type-boolean⧽ | no | Show a dialog when clicking on a marker from which its coordinates may be copied |
static | - | ⧼validator-type-boolean⧽ | no | Make the map static |
zoom | - | ⧼validator-type-integer⧽ | no | The zoom level for the map. For maps with markers this will default to the most zoomed in level that still shows all markers. |
defzoom | - | ⧼validator-type-integer⧽ | 14 | Allows setting the default zoom level of the map. |
layers | layer | ⧼validator-type-string-list⧽ | OpenStreetMap | The layers that will be available in the layer selector. The first layer will be shown when the map loads. |
image layers | image layer, imagelayers, imagelayer | ⧼validator-type-string-list⧽ | ⧼validator-describe-empty⧽ | Image base layers. The first layer will be shown by default. If any images are specified, they will be used instead of the regular map layers. |
overlays | overlaylayers | ⧼validator-type-string-list⧽ | ⧼validator-describe-empty⧽ | The overlay layers that will be shown when the map loads. |
resizable | - | ⧼validator-type-boolean⧽ | no | Makes the map resizable by dragging at its lower right corner. |
fullscreen | enablefullscreen | ⧼validator-type-boolean⧽ | no | Enable fullscreen button |
scrollwheelzoom | scrollzoom | ⧼validator-type-boolean⧽ | yes | Indicates if mouse scrolling should be enabled or not. |
cluster | markercluster | ⧼validator-type-boolean⧽ | no | Allows merging of multiple nearby markers into one marker |
clustermaxzoom | - | ⧼validator-type-integer⧽ | 20 | The maximum zoom level where clusters may exist. |
clusterzoomonclick | - | ⧼validator-type-boolean⧽ | yes | Whether the default behaviour of clicking on a cluster is to zoom into it. |
clustermaxradius | - | ⧼validator-type-integer⧽ | 80 | The maximum radius that a cluster will cover. |
clusterspiderfy | - | ⧼validator-type-boolean⧽ | yes | When you click a cluster at the bottom zoom level we spiderfy it so you can see all of its markers. |
geojson | - | ⧼validator-type-string⧽ | ⧼validator-describe-empty⧽ | URL of a file or name of the page containing GeoJSON data |
clicktarget | - | ⧼validator-type-string⧽ | ⧼validator-describe-empty⧽ | When clicking on the map you will be sent to this URL. %lat% is replaced by the latitude and %long% by the longitude |
staticlocations | locations, points | List of locations | ⧼validator-describe-empty⧽ | A list of locations to add to the map together with the queried data. Like with display_points, you can add a title, description and icon per location using the tilde "~" as separator. |
showtitle | show title | ⧼validator-type-boolean⧽ | yes | Show a title in the marker info window or not. Disabling this is often useful when using a template to format the info window content. |
hidenamespace | hide namespace | ⧼validator-type-boolean⧽ | yes | Show the namespace title in the marker info window |
template | - | ⧼validator-type-string⧽ | no | A template to use to format the info window contents. |
userparam | - | ⧼validator-type-string⧽ | ⧼validator-describe-empty⧽ | A value passed into each template call, if a template is used |
activeicon | - | ⧼validator-type-string⧽ | ⧼validator-describe-empty⧽ | Icon to be displayed instead of default marker, when active page is equal to query result |
pagelabel | - | ⧼validator-type-boolean⧽ | no | When set to "yes", all markers will have an "inlineLabel" with a link to the page containing the coordinates for the marker |
ajaxcoordproperty | - | ⧼validator-type-string⧽ | ⧼validator-describe-empty⧽ | Name of the coordinate property which is used to build the ajax query. |
ajaxquery | - | ⧼validator-type-string⧽ | ⧼validator-describe-empty⧽ | A second query that is sent via ajax to fetch additional coordinates. |
Parameter examples
Dynamic coordinate fetching (ajaxquery)
Initially only includes Berlin onto the map. When moving the map around or changing zoom, the map looks for extra pages with the Has Coordinates property within the visible area. This is great for large data sets where loading all data on the map at once is not feasible.
{{#ask: [[Berlin]] | format=leaflet | ?Has coordinates | ajaxquery = [[Coordinates::+]] | ajaxcoordproperty = Has coordinates | zoom=8 | minzoom=5 }}
Marker clustering
{{#ask: [[Category:City]] | format=leaflet | ?Coordinates | cluster=on }}
Template (simple)
Adding a link to maps.google.com by using a template. See template "Google Maps Link".
{{#ask: [[Category:Locations]] | format=leaflet | ?Coordinates | template=Google Maps Link }}
Template (advanced)
This example shows usage of multiple queried values via the "Location Popup" template.
{{#ask:[[Category:Locations]] | format=leaflet | ?Coordinates | ?Location type | ?Located in | template=Location Popup | showtitle=off }}