Provides geolocation services.

Using geolocation services requires device authorization. Including the Fuse.GeoLocation package in your project will trigger a prompt for this authorization when the app is launched.

Use startListening to get continual location updates. Use location or getLocation for one-time location requests.

You need to add a reference to "Fuse.GeoLocation" in your project file to use this feature.

This module is an EventEmitter, so the methods from EventEmitter can be used to listen to events.

Example

The following example shows how the different modes of operation can be used:

    <JavaScript>
        var Observable = require("FuseJS/Observable");
        var GeoLocation = require("FuseJS/GeoLocation");

        // Immediate
        var immediateLocation = JSON.stringify(GeoLocation.location);

        // Timeout
        var timeoutLocation = Observable("");
        var timeoutMs = 5000;
        GeoLocation.getLocation(timeoutMs).then(function(location) {
            timeoutLocation.value = JSON.stringify(location);
        }).catch(function(fail) {
            console.log("getLocation fail " + fail);
        });

        // Continuous
        var continuousLocation = GeoLocation.observe("changed").map(JSON.stringify);

        GeoLocation.on("error", function(fail) {
            console.log("GeoLocation error " + fail);
        });

        function startContinuousListener() {
            var intervalMs = 1000;
            var desiredAccuracyInMeters = 10;
            GeoLocation.startListening(intervalMs, desiredAccuracyInMeters);
        }

        function stopContinuousListener() {
            GeoLocation.stopListening();
        }

        module.exports = {
            immediateLocation: immediateLocation,
            timeoutLocation: timeoutLocation,
            continuousLocation: continuousLocation,

            startContinuousListener: startContinuousListener,
            stopContinuousListener: stopContinuousListener
        };
    </JavaScript>

    <StackPanel>
        <Text>Immediate:</Text>
        <Text Value="{immediateLocation}" />

        <Text>Timeout:</Text>
        <Text Value="{timeoutLocation}" />

        <Text>Continuous:</Text>
        <Text Value="{continuousLocation}" />

        <Button Text="Start continuous listener" Clicked="{startContinuousListener}" />
        <Button Text="Stop continuous listener" Clicked="{stopContinuousListener}" />
    </StackPanel>
```xml
In the above example we're using the @EventEmitter `observe` method to create an @Observable from the
`"changed"` event. We can also listen to changes by using the `on` method, as follows:

    GeoLocation.on("changed", function(location) { ... })

Locations returned by this module are JavaScript objects of the following form:
```json
    {
        latitude: a number measured in decimal degrees,
        longitude: a number measured in decimal degrees,
        accuracy: a number measured in meters
    }

To handle errors from GeoLocation we can listen to the "error" event, as follows:

GeoLocation.on("error", function(err) { ... })

Location

Namespace
Fuse.GeoLocation
Package
Fuse.GeoLocation 2.9.1
Show Uno properties and methods

Interface of GeoLocation

Inherited from NativeEventEmitterModule

Emit(object[]) uno

Call emit with the given arguments on the underlying JS EventEmitter.

Inherited from NativeModule

Inherited from Module

GetFile : FileSource uno

Returns the file source that will be watched by the Context for changes in Fuse preview. Override in subclasses and return correct file source to support live updates in Fuse preview.

Inherited from object

Attached UX Attributes

GlobalKey (attached by Resource) : string ux

The ux:Global attribute creates a global resource that is accessible everywhere in UX markup.

Implemented Interfaces