SDKsuni-app / uni-app x
Create a location message
Construct a location message from geographical coordinates and a location description.
Invoke createLocationMessage() to embed location metadata and GPS coordinates into a pending message object. The SDK persists coordinates and descriptive text; it does not handle GPS sensor polling, reverse geocoding, or map rendering.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
descriptionText | string | Yes | Human-readable location name or address description. |
longitude | number | Yes | Longitude coordinate in the range [-180, 180]. |
latitude | number | Yes | Latitude coordinate in the range [-90, 90]. |
Code example
import { createLocationMessage } from '@/uni_modules/unix-openim-sdk'
const message = await createLocationMessage({
descriptionText: 'Shenzhen Bay Park',
longitude: 113.9516,
latitude: 22.4864,
})
if (message == null) returnEnsure coordinates are obtained from a validated location provider using a consistent coordinate reference system (such as WGS-84 or GCJ-02 according to your app's map SDK).
Return value
The Promise resolves with an OpenIMMessageItem | null object.
State changes after the call
Pass the constructed message item to Send a message. Track message status using clientMsgID.
Was this page helpful?