Location Model

Both the Address Model and Visitor Model are extensions of the Location Model.

# Public Properties

# lat

float - Latitude of location.

# lng

float - Longitude of location.

# coords

object - Alias for getCoords().

# Public Methods

# hasCoords()

Determine whether the location has valid coordinates.

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

Returns

  • bool - Whether the location has functional coordinates.

# getCoords()

Get the coordinates of a location.

Returns

  • object - Get the location coordinates as a coords 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 a separate Location Model (can be an Address or Visitor model).
  • $units (string) - Unit of measurement (mi,km,miles,kilometers).

Returns

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

# linkToMap(parameters = {})

Generate a link to a Google Map, displaying a single marker of this location.

<a href="{{ location.linkToMap() }}">See Location in Google Maps</a>

Arguments

Returns

  • string - Generate a link to see this location in Google Maps.

# linkToDirections(parameters = {}, origin = null)

Generate a link to a Google Map, displaying directions to this location.

<a href="{{ location.linkToDirections() }}">Get Directions</a>

Arguments

Returns

  • string - Generate a link to get directions to this location in Google Maps.

# linkToStreetView(parameters = {})

Generate a link to a Google Map, displaying this location as a street view panorama.

<a href="{{ location.linkToStreetView() }}">Open in Google Street View</a>

Arguments

Returns

  • string - Generate a link to see a street view panorama of this location in Google Maps.

# linkToArea(parameters = {})

Generate a link to a Google Map, displaying the broader area surrounding this location.

<a href="{{ location.linkToArea() }}">See area in Google Maps</a>

Arguments

Returns

  • string - Generate a link to see this general area in Google Maps.

Displaying a Marker

The linkToArea method will show a map centered on the desired location, but it will not display a marker. If you would like a marker to appear, use the linkToMap method instead.