transformLocation(params: Object)

Requires:
MapKit≥3.2.2@ray-js/ray≥1.4.38
Platforms:
iOSAndroid
import { map } from '@ray-js/ray';

const { transformLocation } = map;

// Promise usage
try {
  const res = await transformLocation({ ...params });
  console.log(res);
} catch (err) {
  console.log(err.errorMsg);
}

Description

Convert latitude/longitude or address

Parameters

PropertyTypeRequiredDescription
typestringYeswgs84 returns GPS coordinates; gcj02 returns coordinates usable with openLocation
latitudenumberYesLatitude, range -90 to 90; negative values indicate south
longitudenumberYesLongitude, range -180 to 180; negative values indicate west
complete() => voidNoCompletion callback (executed on both success and failure)
success(params: Object) => voidNoCallback on successful API call
fail(params: Object) => voidNoFailure callback
success callback parameters
PropertyTypeDescriptionMapKit Since
latitudenumberLatitude, range -90 to 90; negative values indicate south-
longitudenumberLongitude, range -180 to 180; negative values indicate west-
cityNamestringCity name-
streetNamestringStreet name-
addressstringLocation name. Historically, iOS returned an Array; use the formatAddress field instead-
formatAddressstringFormatted addressv3.6.0
countryCodestringCountry code-
postalCodestringPostal code-
countryNamestringCountry name-
provincestringProvince name-
districtstringDistrict/county name (second-level administrative region)-
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

None

Examples

import { map } from '@ray-js/ray'

map.transformLocation({
  type: "gcj02",
  latitude: 39.908823,
  longitude: 116.39747,
  success: data => {
    console.log(data);
  },
  fail: error => {
    console.error(error);
  },
});