Customizing query results: Difference between revisions

From Maps for MediaWiki
mNo edit summary
mNo edit summary
Line 58: Line 58:
  | template=City Popup
  | template=City Popup
  | showtitle=off
  | showtitle=off
| hidenamespace=on
}}
}}
</pre>
</pre>
Line 69: Line 70:
  | template=City Popup
  | template=City Popup
  | showtitle=off
  | showtitle=off
| hidenamespace=on
  | scrollzoom=off
  | scrollzoom=off
}}
}}

Revision as of 00:50, 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:

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

It has a population of {{{Population}}} and surface area of {{{Surface area}}} km²
{{#ask:[[Category:Cities]]
 | format=map
 | ?Coordinates
 | ?Located in
 | ?Population
 | ?Surface area
 | template=City Popup
 | showtitle=off
 | hidenamespace=on
}}
Loading map...

Template parameters

These parameters are available inside of templates:

  • title - the title of the page or subject
  • 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²