location (GPS)

Type Event
Revision 2018.3242
Keywords location, GPS


These are location events generated by the GPS hardware. They are only sent to the global Runtime object when the app requests them with a statement like Runtime:addEventListener( "location", locationHandler ).

See the individual property documentation pages below for examples.



In the location event listener, event.errorCode should be checked in case of a location error.


To enable GPS on Android devices, you must add the following permission(s) to the build.settings file:

settings =
    android =
        usesPermissions =
            -- Permission to retrieve current location from the GPS
            -- Permission to retrieve current location from WiFi or cellular service


On iOS, event.errorCode will be non-nil if the user disabled location services for the app.


You must adjust your app's entitlements to use location events for macOS apps. See here for details.


Location services are not currently supported on Windows. While the Corona Simulator for Windows will synthesize a fake location event for testing purposes, Windows desktop apps will not do this. As a consequence, system.hasEventSource( "location" ) will return true in the Corona Simulator for Windows but false in Windows desktop apps.