Difference between revisions of "Geolocation"

From GiderosMobile
 
(27 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
'''Supported platforms:''' android, ios<br/>
+
<!-- GIDEROSOBJ:Geolocation -->
 +
'''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform winrt.png]]<br/>
 
'''Available since:''' Gideros 2012.8<br/>
 
'''Available since:''' Gideros 2012.8<br/>
 +
'''Inherits from:''' [[Object]]<br/>
 +
 
=== Description ===
 
=== Description ===
<br />
+
The '''Geolocation''' Class is used to configure the parameters and dispatching of location and heading related events.
The `Geolocation` class is used to configure the parameters and dispatching of location and heading related events.<br />
+
 
<br />{|-
+
=== Examples ===
| style="width: 50%;"|
+
<syntaxhighlight lang="lua">
 +
geolocation = Geolocation.new()
 +
 
 +
local function onLocationUpdate(event)
 +
print("location: ", event.latitude, event.longitude, event.altitude)
 +
end
 +
 
 +
local function onHeadingUpdate(event)
 +
print("heading: ", event.magneticHeading, event.trueHeading)
 +
end
 +
 
 +
geolocation:addEventListener(Event.LOCATION_UPDATE, onLocationUpdate)
 +
geolocation:addEventListener(Event.HEADING_UPDATE, onHeadingUpdate)
 +
geolocation:start()
 +
</syntaxhighlight>
 +
 
 +
{|-
 +
| style="width: 50%; vertical-align:top;"|
 
=== Methods ===
 
=== Methods ===
[[Geolocation.getAccuracy]] - Geolocation - returns the previously set desired accuracy<br/>
+
[[Geolocation.getAccuracy]] ''returns the previously set desired accuracy''<br/><!--GIDEROSMTD:Geolocation.getAccuracy() returns the previously set desired accuracy-->
[[Geolocation.getThreshold]] - Geolocation - returns the previously set minimum distance threshold<br/>
+
[[Geolocation.getThreshold]] ''returns the previously set minimum distance threshold''<br/><!--GIDEROSMTD:Geolocation.getThreshold() returns the previously set minimum distance threshold-->
[[Geolocation.isAvailable]] - Geolocation - does this device have the capability to determine current location?<br/>
+
[[Geolocation.isAvailable]] ''does this device have the capability to determine current location?''<br/><!--GIDEROSMTD:Geolocation.isAvailable() does this device have the capability to determine current location?-->
[[Geolocation.isHeadingAvailable]] - Geolocation - does this device have the capability to determine heading?<br/>
+
[[Geolocation.isHeadingAvailable]] ''does this device have the capability to determine heading?''<br/><!--GIDEROSMTD:Geolocation.isHeadingAvailable() does this device have the capability to determine heading?-->
[[Geolocation.new]] - Creates new Geolocation instance<br/>
+
[[Geolocation.new]] ''creates new Geolocation instance''<br/><!--GIDEROSMTD:Geolocation.new() creates new Geolocation instance-->
[[Geolocation.setAccuracy]] - of the location data<br/>
+
[[Geolocation.setAccuracy]] ''sets the accuracy of the location data''<br/><!--GIDEROSMTD:Geolocation.setAccuracy(accuracy) sets the accuracy of the location data-->
[[Geolocation.setThreshold]] - threshold<br/>
+
[[Geolocation.setThreshold]] ''sets the threshold''<br/><!--GIDEROSMTD:Geolocation.setThreshold(threshold) sets the threshold-->
[[Geolocation:start]] - Geolocation - starts the generation of updates that report the current location and heading<br/>
+
 
[[Geolocation:startUpdatingHeading]] - Geolocation - starts the generation of updates that report the heading<br/>
+
[[Geolocation:start]] ''starts the generation of updates that report the current location and heading''<br/><!--GIDEROSMTD:Geolocation:start() starts the generation of updates that report the current location and heading-->
[[Geolocation:startUpdatingLocation]] - Geolocation - starts the generation of updates that report the current location<br/>
+
[[Geolocation:startUpdatingHeading]] ''starts the generation of updates that report the heading''<br/><!--GIDEROSMTD:Geolocation:startUpdatingHeading() starts the generation of updates that report the heading-->
[[Geolocation:stop]] - Geolocation - stops the generation of updates that report the current location and heading<br/>
+
[[Geolocation:startUpdatingLocation]] ''starts the generation of updates that report the current location''<br/><!--GIDEROSMTD:Geolocation:startUpdatingLocation() starts the generation of updates that report the current location-->
[[Geolocation:stopUpdatingHeading]] - Geolocation - stops the generation of updates that report the heading<br/>
+
[[Geolocation:stop]] ''stops the generation of updates that report the current location and heading''<br/><!--GIDEROSMTD:Geolocation:stop() stops the generation of updates that report the current location and heading-->
[[Geolocation:stopUpdatingLocation]] - Geolocation - stops the generation of updates that report the current location<br/>
+
[[Geolocation:stopUpdatingHeading]] ''stops the generation of updates that report the heading''<br/><!--GIDEROSMTD:Geolocation:stopUpdatingHeading() stops the generation of updates that report the heading-->
| style="width: 50%;"|
+
[[Geolocation:stopUpdatingLocation]] ''stops the generation of updates that report the current location''<br/><!--GIDEROSMTD:Geolocation:stopUpdatingLocation() stops the generation of updates that report the current location-->
 +
 
 +
| style="width: 50%; vertical-align:top;"|
 
=== Events ===
 
=== Events ===
[[Event.ERROR]]<br/>
+
[[Event.ERROR]]<br/><!--GIDEROSEVT:Event.ERROR error-->
[[Event.HEADING_UPDATE]]<br/>
+
[[Event.HEADING_UPDATE]]<br/><!--GIDEROSEVT:Event.HEADING_UPDATE headingUpdate-->
[[Event.LOCATION_UPDATE]]<br/>
+
[[Event.LOCATION_UPDATE]]<br/><!--GIDEROSEVT:Event.LOCATION_UPDATE locationUpdate-->
 
=== Constants ===
 
=== Constants ===
 
|}
 
|}
 +
 +
{{GIDEROS IMPORTANT LINKS}}

Latest revision as of 06:54, 10 October 2023

Supported platforms: Platform android.pngPlatform ios.pngPlatform winrt.png
Available since: Gideros 2012.8
Inherits from: Object

Description

The Geolocation Class is used to configure the parameters and dispatching of location and heading related events.

Examples

geolocation = Geolocation.new()

local function onLocationUpdate(event)
	print("location: ", event.latitude, event.longitude, event.altitude)
end

local function onHeadingUpdate(event)
	print("heading: ", event.magneticHeading, event.trueHeading)
end

geolocation:addEventListener(Event.LOCATION_UPDATE, onLocationUpdate)
geolocation:addEventListener(Event.HEADING_UPDATE, onHeadingUpdate)
geolocation:start()

Methods

Geolocation.getAccuracy returns the previously set desired accuracy
Geolocation.getThreshold returns the previously set minimum distance threshold
Geolocation.isAvailable does this device have the capability to determine current location?
Geolocation.isHeadingAvailable does this device have the capability to determine heading?
Geolocation.new creates new Geolocation instance
Geolocation.setAccuracy sets the accuracy of the location data
Geolocation.setThreshold sets the threshold

Geolocation:start starts the generation of updates that report the current location and heading
Geolocation:startUpdatingHeading starts the generation of updates that report the heading
Geolocation:startUpdatingLocation starts the generation of updates that report the current location
Geolocation:stop stops the generation of updates that report the current location and heading
Geolocation:stopUpdatingHeading stops the generation of updates that report the heading
Geolocation:stopUpdatingLocation stops the generation of updates that report the current location

Events

Event.ERROR
Event.HEADING_UPDATE
Event.LOCATION_UPDATE

Constants