The Maps extension supports geocoding at all places where you can specify a location. You can access this functionality directly using the #geocode
parser function, which gives you the coordinates for the address you provide to it.
Syntax[edit]
{{#geocode:<your address>|format=<coordinate format>|directional=<yes/no>}}
Usecases[edit]
You can use #geocode
inline with some text or in an infobox.
The Brandenburg Gate is in Berlin at {{#geocode:Brandenburg Gate}}
Result: The Brandenburg Gate is in Berlin at 52° 30' 58.57" N, 13° 22' 39.73" E
Another common use case is to store coordinates in SMW using the coordinate data type, so they can be queried.
[[Has coordinates::{{#geocode: Brandenburg Gate}}]]
Parameters[edit]
Parameter | Default | Usage |
---|---|---|
location | required | The address you want to geocode. |
format | dms (changeable in wiki config with egMapsCoordinateNotation )
|
The format to convert the coordinates to. See available coordinate formats |
directional | yes (changeable in wiki config with egMapsCoordinateDirectional )
|
Indicates if the coordinates should be outputted directional or not. Must be either yes or no. |
Examples[edit]
Basic syntax[edit]
{{#geocode:New York}}
Result: 40° 42' 45.82" N, 74° 0' 21.65" W
Specifying the output coordinate format[edit]
{{#geocode:location=New York City|format=float|directional=no}}
Result: 40.712728, -74.006015
{{#geocode:New York City|format=dms|directional=yes}}
Result: 40° 42' 45.82" N, 74° 0' 21.65" W
Passing along coordinates[edit]
This is to show that if you have a dynamic value that can be either an address or a set of coordinates, you can safely pass it to the #geocode
parser function. If you want to convert coordinates into a different format, it is better to use the #coordinates
parser function.
{{#geocode:40.7142691, -74.0059729}}
Result: 40° 42' 51.37" N, 74° 0' 21.50" W