Browse SDKs · uni-app / uni-app x
Platform
SDKsuni-app / uni-app x

Create a location message

Construct a location message from geographical coordinates and a location description.

Copy

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

ParameterTypeRequiredDescription
descriptionTextstringYesHuman-readable location name or address description.
longitudenumberYesLongitude coordinate in the range [-180, 180].
latitudenumberYesLatitude 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) return

Ensure 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.