Difference between revisions of "Geolocation"
Line 6: | Line 6: | ||
The `Geolocation` class is used to configure the parameters and dispatching of location and heading related events.<br /> | The `Geolocation` class is used to configure the parameters and dispatching of location and heading related events.<br /> | ||
<br /> | <br /> | ||
+ | === Examples === | ||
+ | '''Example'''<br/> | ||
+ | <source lang="lua">geolocation = Geolocation.new()<br /> | ||
+ | <br /> | ||
+ | local function onLocationUpdate(event)<br /> | ||
+ | print("location: ", event.latitude, event.longitude, event.altitude)<br /> | ||
+ | end<br /> | ||
+ | <br /> | ||
+ | local function onHeadingUpdate(event)<br /> | ||
+ | print("heading: ", event.magneticHeading, event.trueHeading)<br /> | ||
+ | end<br /> | ||
+ | <br /> | ||
+ | geolocation:addEventListener(Event.LOCATION_UPDATE, onLocationUpdate)<br /> | ||
+ | geolocation:addEventListener(Event.HEADING_UPDATE, onHeadingUpdate)<br /> | ||
+ | geolocation:start()</source> | ||
{|- | {|- | ||
| style="width: 50%;"| | | style="width: 50%;"| |
Revision as of 10:44, 23 August 2018
Supported platforms: android, ios
Available since: Gideros 2012.8
Description
The `Geolocation` class is used to configure the parameters and dispatching of location and heading related events.
Examples
Example
geolocation = Geolocation.new()<br />
<br />
local function onLocationUpdate(event)<br />
print("location: ", event.latitude, event.longitude, event.altitude)<br />
end<br />
<br />
local function onHeadingUpdate(event)<br />
print("heading: ", event.magneticHeading, event.trueHeading)<br />
end<br />
<br />
geolocation:addEventListener(Event.LOCATION_UPDATE, onLocationUpdate)<br />
geolocation:addEventListener(Event.HEADING_UPDATE, onHeadingUpdate)<br />
geolocation:start()
MethodsGeolocation.getAccuracy - Geolocation - returns the previously set desired accuracy |
EventsEvent.ERROR Constants |