From Mapping on MediaWiki
Jump to: navigation, search
Calculates the distance between two points
Min version:
Max version:
still supported
Function implementation:
Tag implementation:

You can use the #geodistance parser function to calculate the geographical distance between two points, from and to any of the supported formats.


This function is part of the Maps extension, so you should have Maps installed in order to use it. This parser function was added in Maps 0.6, and has undergone backwards compatible parameter changes in 0.6.2.



{{#geodistance:{starting location}|{ending location}}


This parser function supports use of so called 'default parameters'. This allows you to simply pass along values, without writing the parameter name= part. You can mix this notation together with using named parameters, but must at all times keep the default ones in the correct order. The order is location, location, unit.

Parameter Aliases Default Usage Notes
location1 from required The first point in the set to calculate the distance between. Alias since 0.7
location2 to required The second point in the set to calculate the distance between. Alias since 0.7
unit - configurable The unit the output the distance in. Configurable since 0.6.2. Defaulted to 'km' in earlier versions.
decimals - configurable The maximum amount of fractional digits to use in the resulting value. Added in 0.6.2
geoservice - configurable The geocoding service to use to geocode any addresses. Added in 0.7
mappingservice - configurable The mapping service this is used together with. This can affect the default geocoding service value. Added in 0.7

Both locations can be either a set of coordinates or an address that will then be geocoded.


Calculating the distance between two points

{{#geodistance:55.7557860° N, 37.6176330° W|-42.42, 42.42}}

Results into: 13,239,091.81 m

{{#geodistance:New York|Los Angeles|unit=km}}
Results into:
Fatal error: Parameter location2 must be a valid location.

<geodistance from="New York City" to="Los Angeles" unit="miles" geoservice="geonames" />

Results into: 2,445.56 miles

See also

This documentation page applies to all (Semantic) Maps versions from 0.7 to the most current version.
Other versions: 0.6 – 0.6.6      

Geodistance en 0.7