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