Location Model

The Address Model is an extension of the Location Model.

# Public Properties

# lng

float - Longitude of location.

# lat

float - Latitude of location.

# coords

object - Alias for getCoords().

# Public Methods

# hasCoords()

Determine whether the location has valid coordinates.

{% if location.hasCoords() %}
    Longitude: {{ location.lng }}
    Latitude:  {{ location.lat }}
{% endif %}

Returns

  • bool - Whether the location has functional coordinates.

# getCoords()

Get the coordinates of a location.

Returns

  • object - Get the location coords as a coordinates JSON object.

# getDistance(location, units = 'miles')

Get the distance between two points.

{% set distance = entry.homeAddress.getDistance(entry.businessAddress) %}

Arguments

  • $location (mixed) - A set of coordinates, or separate Location Model (or Address model).
  • $units (string) - Unit of measurement (mi,km,miles,kilometers).

Returns

  • float|null - Calculates the distance between the two points.