Help:Creating a map centered on the coordinate for your page, with nearby 'pages' shown

From semantic-mediawiki.org
Semantic extension(s): Semantic Maps
Further extension(s): Variables
Keyword(s): maps · nearby

Description:

Problem[edit]

Draw a map centred on the coordinate for the current page, with nearby 'pages' also show.

Solution[edit]

For convenience we use the excellent Variables extension, and of course, the the Semantic Maps extension.

This code is suitable for putting in a template. It assumes the template is passed some 'geocode-able' fields, address, city, and country. I've used some default values for those fields below, so it will work without being invoked via a template call.

{{#vardefine:coord
  |{{#geocode:{{{address|Largo Gerolamo Gaslini, 5}}},{{{City|Genova}}},{{{country|Italy}}}|nominatim}}
}}

{{#set: Has coordinates = {{#var:coord}} }}

<div style="float: right; width:45%">
{{#ask:
  [[Category: Laboratory]]
  |?Has coordinates 
  | format = map
  | center = {{#var:coord}}
  | zoom = 13
}}
</div>