Spherical

The OpenLayers.Spherical namespace includes utility functions for calculations on the basis of a spherical earth (ignoring ellipsoidal effects), which is accurate enough for most purposes.

Relevant links

Summary
SphericalThe OpenLayers.Spherical namespace includes utility functions for calculations on the basis of a spherical earth (ignoring ellipsoidal effects), which is accurate enough for most purposes.
Functions
computeDistanceBetweenComputes the distance between two LonLats.
computeHeadingComputes the heading from one LonLat to another LonLat.

Functions

computeDistanceBetween

OpenLayers.Spherical.computeDistanceBetween = function(from,
to,
radius)

Computes the distance between two LonLats.

Parameters

from{OpenLayers.LonLat} or {Object} Starting point.  A LonLat or a JavaScript literal with lon lat properties.
to{OpenLayers.LonLat} or {Object} Ending point.  A LonLat or a JavaScript literal with lon lat properties.
radius{Float} The radius.  Optional.  Defaults to 6378137 meters.

Returns

{Float} The distance in meters.

computeHeading

OpenLayers.Spherical.computeHeading = function(from,
to)

Computes the heading from one LonLat to another LonLat.

Parameters

from{OpenLayers.LonLat} or {Object} Starting point.  A LonLat or a JavaScript literal with lon lat properties.
to{OpenLayers.LonLat} or {Object} Ending point.  A LonLat or a JavaScript literal with lon lat properties.

Returns

{Float} The heading in degrees.

OpenLayers.Spherical.computeDistanceBetween = function(from,
to,
radius)
Computes the distance between two LonLats.
OpenLayers.Spherical.computeHeading = function(from,
to)
Computes the heading from one LonLat to another LonLat.
This class represents a longitude and latitude pair
Close