Location sharing

Allow users to share their location within a conversation.

View as Markdown

Location sharing lets users send a specific point on the map as a message, for example to share their current location, or the location of a meeting point. You could also use location sharing to give customers updates on the location of their order or delivery.

A user shares their location in the chat, showing a Google maps thumbnail with a location marker and a url.

A user shares their current location in the chat

In the TalkJS chat UI, a shared location is rendered as a link to Google Maps, with a thumbnail showing the surrounding area and a pin at the specified coordinate.

Location sharing requires an HTTPS-secured connection, due to browser restrictions on geolocation access. Moreover, the user must give permission for the browser or app to access their location data.

Enable location sharing

You can enable or disable location sharing for each user role in the Chat UI page of your TalkJS dashboard. Select the role you want to edit, then enable or turn off the Allow location sharing setting in the Features section.

Send locations programmatically

You can also send a message containing a location using the REST API, by including a location content block in the message's content array:

1{
2 "type": "location",
3 "latitude": number,
4 "longitude": number
5}

latitude must be a number between -90 and 90, and longitude must be a number between -180 and 180.

Note that you can only include locations for regular user messages, not system messages. In addition, the user for which you programmatically share a location must be a participant in the conversation, not a guest.

See also