Customizing query results

From Maps for MediaWiki
Revision as of 02:37, 16 May 2020 by Jeroen De Dauw (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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[edit | edit source]

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[edit | edit source]

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[edit | edit source]

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[edit | edit source]

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[edit | edit source]

{{#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...