Customizing query results: Difference between revisions

From Maps for MediaWiki
mNo edit summary
mNo edit summary
 
Line 41: Line 41:
Templates are specified with the <code>template</code> parameter, which takes the name of a template on your wiki. The <code>showtitle</code> parameter is often useful here, as setting it to <code>no</code> allows you to have full control over the popup content.
Templates are specified with the <code>template</code> parameter, which takes the name of a template on your wiki. The <code>showtitle</code> parameter is often useful here, as setting it to <code>no</code> allows you to have full control over the popup content.


This example shows usage of multiple queried values via the [[Template:City Popup|"City Popup" template]]:
This example shows usage of multiple queried values via the [[Template:City Popup|"City Popup" template]].
 
<pre>
The city '''[[{{{title}}}]]''' is located in [[{{{Located in}}}]].
 
It has a population of {{{Population}}} and surface area of {{{Surface area}}} km²
</pre>


<pre>
<pre>
Line 60: Line 54:
  | hidenamespace=on
  | hidenamespace=on
}}
}}
</pre>
<pre>
The city '''[[{{{title}}}]]''' is located in [[{{{Located in}}}]].
It has a population of {{{Population}}} and surface area of {{{Surface area}}} km²
</pre>
</pre>


Line 103: Line 103:
  | hidenamespace=on
  | hidenamespace=on
}}
}}
</pre>
<pre>
[[{{{City image}}}|200px]]
The city '''[[{{{fulltitle}}}|{{{title}}}]]'''
</pre>
</pre>



Latest revision as of 01:37, 16 May 2020

This page is about customization of the information that is shown when clicking a marker or shape on a map showing the result of a Semantic MediaWiki query.

Default behavior

By default the name of the page is shown. If addition properties are queried, they are shown in a list below the title.

{{#ask:[[Category:Cities]]
 | format=map
 | ?Coordinates
 | ?Located in
 | ?Population
 | ?Surface area
}}
Loading map...

Parameters

Parameters relevant for customization:

  • template
  • showtitle
  • hidenamespace
  • userparam

For a full list of parameters you can use in the map formats, see Leaflet SMW queries and Google Maps SMW queries.

Templates

Templates allow you to fully customize what gets shown in the popups.

Templates are specified with the template parameter, which takes the name of a template on your wiki. The showtitle parameter is often useful here, as setting it to no allows you to have full control over the popup content.

This example shows usage of multiple queried values via the "City Popup" template.

{{#ask:[[Category:Cities]]
 | format=map
 | ?Coordinates
 | ?Located in
 | ?Population
 | ?Surface area
 | template=City Popup
 | showtitle=off
 | hidenamespace=on
}}
The city '''[[{{{title}}}]]''' is located in [[{{{Located in}}}]].

It has a population of {{{Population}}} and surface area of {{{Surface area}}} km²
Loading map...

Template parameters

These parameters are available inside of templates:

  • title - the title of the page or subject. Includes namespace unless hidenamespace=on
  • fulltitle - the title of the page or subject, including namespace. Available since Maps 7.20
  • latitude - latitude of the location as number (float)
  • longitude - longitude of the location as number (float)
  • userparam - the value of the userparam parameter in the ask query

If additional properties are queried, they are also available as shown in the above example. Named parameters for additional properties are only available since Maps 7.19. Positional numeric parameters can be used instead, as shown below:

The city '''[[{{{title}}}]]''' is located in [[{{{1}}}]].

It has a population of {{{2}}} and surface area of {{{3}}} km²

Example: template with image

{{#ask:[[Category:Cities]] [[City image::+]]
 | format=googlemaps
 | ?Coordinates
 | ?City image
 | template=City Image Popup
 | showtitle=off
 | hidenamespace=on
}}
[[{{{City image}}}|200px]]

The city '''[[{{{fulltitle}}}|{{{title}}}]]'''
Loading map...