ℹ️ Location API data

Sending coordinates via Micropub

When using the JSON version of the Micropub API, Micro.blog can store location data with a blog post, including venue name, URL, latitude, and longitude.

To just send coordinates, use the location property:

POST /micropub
Authorization: Bearer 123456789
Content-Type: application/json

{
    "type": [
        "h-entry"
    ],
    "properties": {
        "published": [
            "2019-10-27T14:51:32-05:00"
        ],
        "content": [
            "Texas Book Festival."
        ],
        "location": [
            {
                "type": [
                    "h-adr"
                ],
                "properties": {
                    "latitude": [
                        30.273892650534542
                    ],
                    "longitude": [
                        -97.74060666521329
                    ]
                }
            }
        ]
    }
}

If you are making a check-in post with venue information, use the checkinproperty:

POST /micropub
Authorization: Bearer 123456789
Content-Type: application/json

{
    "type": [
        "h-entry"
    ],
    "properties": {
        "published": [
            "2019-10-27T14:51:32-05:00"
        ],
        "content": [
            "Texas Book Festival."
        ],
        "checkin": [
            {
                "type": [
                    "h-card"
                ],
                "properties": {
                    "name": [
                        "Texas Capitol Grounds"
                    ],
                    "url": [
                        "https://foursquare.com/v/4d8a30f199c2a1cd53508bd7"
                    ],
                    "latitude": [
                        30.273892650534542
                    ],
                    "longitude": [
                        -97.74060666521329
                    ]
                }
            }
        ]
    }
}

This is a subset of the full Micropub requests that apps like OwnYourSwarm send.

Embedding maps

The default Micro.blog themes do not currently do anything with this information. You can create a custom theme to access the coordinates as custom parameters, like this:

{{ with .Params.location }}
  <img src="https://example-mapping-service.com/?center={{ .latitude }},{{ .longitude}}">
{{ end }}

You can also use our built-in maps renderer like this:

{{ with .Params.location.map_url }}
  <img src="{{ . }}">
{{ end }}

You can also include a size parameter at the end for larger maps — “s”, “m”, “l”, or “xl” — like &size=m for a medium (600x600) map. The base map_url already has its own parameters, so using & to append new parameters is needed.

The available parameters are:

  • location.name
  • location.url
  • location.latitude
  • location.longitude
  • location.map_url

The venue name is automatically prepended to post content so that no theme changes are necessary.