Location Messages

A Location Message has a few uses:

  • Show a map of a location; perhaps a restaurant to meet at? A house to sell? Or just your current position in the world
  • Show an address, for example, as a sub-message-view of a Receipt Message

Just the map:

Just a Map
Map with Details
Map with Address
Name Required Type Description
mime_type Yes String application/vnd.layer.location+json
latitude No Number Use lat/long and/or street address
longitude No Number Use lat/long and/or street address
zoom No Number Zoom level from 1 - 18; defaults to 16; see Google Maps API
title No String Title for the Location Message
description No String Rendered below the title. If present, will be rendered instead of an Address.
street1 No String String address line 1
street2 No String String address line 2
city No String City that the location is within
administrative_area No String Name of the state or comparable unit of region
postal_code No String Zipcode or some regionally comparable concept
country No String Country code or name
custom_data No Object Data that will not be understood by any Layer provided Renderer, but which will allow additional context to be stored in the Message so your server can better understand it when next your server sees the Message

To only show the map, and no other information, include latitude and longitude, and leave out titles, addresses and descriptions:

{
	"sender_id": "layer:///identities/frodo-the-dodo",
	"parts": [
		{
			"id": "layer:///messages/GENERATE_A_UUID/parts/GENERATE_A_UUID",
			"mime_type": "application/vnd.layer.location+json;role=root",
			"body": JSON.stringify({
        "latitude": 37.7734858,
        "longitude": -122.3916087
      })
		}
	]
}

To show the Address as text under the Map, leave the description empty:

{
	"sender_id": "layer:///identities/frodo-the-dodo",
	"parts": [
		{
			"id": "layer:///messages/GENERATE_A_UUID/parts/GENERATE_A_UUID",
			"mime_type": "application/vnd.layer.location+json;role=root",
			"body": JSON.stringify({
        "city": "San Francisco",
        "title": "Layer Inc",
        "postalCode": "94107",
        "administrativeArea": "CA",
        "street1": "655 4th st"
      })
		}
	]
}