Livecode Wiki

A Message sent to the current card of the default stack when the location of the device changes. If there is a message handler by the same name in the message path, then it will be executed.

Message[]

Syntax:

locationChanged <latitude>, <longitude>, <altitude>

The parameter "latitude" is the latitude of the device. The parameter "longitude" is the longitude of the device. The parameter "altitude" is the altitude of the device.

The locationChanged message is sent to the current card of the default stack when the location of the device changes.

If location tracking cannot be started (typically due to the user 'not allowing' access to CoreLocation) then a trackingError message is sent instead.

Changes: In version 8.1 GPS behavior on iOS was changed to bring it inline with the behavior on Android. On both platforms, the location reading returned by the `mobileSensorReading` function is that which was sent with the last system `locationChanged` event.

Message handler[]

Examples:

on locationChanged pLatitude, pLongitude, pAltitude
   put pAltitude into field "altitude"
end locationChanged
on locationChanged
   put mobileSensorReading("location", true) into theLocation
    -- update the marker on the map showing the current location
   updateMapPosition theLocation
end locationChanged

Use the locationChanged Message handler if you want to perform tasks when the location of the device changes.

See also: mobileStopTrackingSensor, mobileStartTrackingSensor, mobileGetLocationHistoryLimit, mobileSensorAvailable, mobileSensorReading, mobileLocationAuthorizationStatus, locationChanged & trackingError.