SDKsHarmonyOSEnterprise
Create location message
Create a location message with descriptive text and geographic coordinates.
The SDK embeds provided location descriptions and coordinates into the message payload without performing geolocation, reverse geocoding, or map rendering.
Code example
import sdk, { CreateLocationMessageReq, CreateLocationMessageResp } from '@openimsdk/imsdk';
const request: CreateLocationMessageReq = {
description: 'Shenzhen Bay Park',
longitude: 113.9516,
latitude: 22.4864,
};
const response: CreateLocationMessageResp = await sdk.createLocationMessage(request);
const message = response.message;Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
description | string | Yes | Human-readable address or landmark name. |
longitude | number | Yes | Longitude coordinate (-180 to 180). |
latitude | number | Yes | Latitude coordinate (-90 to 90). |
Return value
Returns a Promise resolving to CreateLocationMessageResp:
| Property | Type | Description |
|---|---|---|
message | IMMessage | Locally instantiated location message object. |
State changes after the call
Longitude must range between -180 and 180, and latitude must range between -90 and 90. Ensure coordinates use a consistent spatial reference frame (such as WGS-84 or GCJ-02). This operation only instantiates the IMMessage object locally; call Send message to dispatch it.
Was this page helpful?