Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

intel/cordova-plugin-intel-xdk-geolocation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DISCONTINUATION OF PROJECT.

This project will no longer be maintained by Intel.

Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project.

Intel no longer accepts patches to this project.

If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the open source software community, please create your own fork of this project. DISCONTINUATION OF PROJECT. This project will no longer be maintained by Intel. Intel will not provide or guarantee development of or support for this project, including but not limited to, maintenance, bug fixes, new releases or updates. Patches to this project are no longer accepted by Intel. In an effort to support the developer community, Intel has made this project available under the terms of the Apache License, Version 2. If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the community, please create your own fork of the project.

intel.xdk.geolocation

Make your application aware of where it is currently located

This Intel XDK Cordova plugin and API has been deprecated. Please use the equivalent standard Cordova geolocation plugin instead.

Methods

  • clearWatch — This method stops the process started by watchPosition when it is passed the appropriate watch timer object.
  • getCurrentPosition — Use this command to get the current location of the device.
  • watchPosition — Use this command rather than the getCurrentLocation command to track progress during a trip rather than just getting a single position.

clearWatch

This method stops the process started by watchPosition when it is passed the appropriate watch timer object.

intel.xdk.geolocation.clearWatch(watchTimer);

Available Platforms

  • Apple iOS
  • Google Android
  • Microsoft Windows 8 - BETA
  • Microsoft Windows Phone 8 - BETA

Parameters

Example

var geolocationWatchTimer = 
    intel.xdk.geolocation.watchPosition(suc,fail,options);
intel.xdk.geolocation.clearWatch(geolocationWatchTimer);

getCurrentPosition

Use this command to get the current location of the device.

intel.xdk.geolocation.getCurrentPosition(successFunction,errorFunction);

Description

Use this command to get the current location. This command asynchronously acquires the approximate latitude and longitude of the device. When data is available, the success function is called. If there is an error getting position data, the error function is called.

Available Platforms

  • Apple iOS
  • Google Android
  • Microsoft Windows 8 - BETA
  • Microsoft Windows Phone 8 - BETA

Parameters

  • successFunction: When data is available, this success function is called.
  • errorFunction: If there is an error getting position data, the error function is called.

Example

var getLocation = function()
{
    var suc = function(p){
        alert("geolocation success");
        if (p.coords.latitude != undefined)
        {
            currentLatitude = p.coords.latitude;
            currentLongitude = p.coords.longitude;
        }

    };
    var fail = function(){
        alert("geolocation failed");
        getLocation();
    };

    intel.xdk.geolocation.getCurrentPosition(suc,fail);
}

watchPosition

Use this command rather than the getCurrentLocation command to track progress during a trip rather than just getting a single position.

var watchTimer = 
    intel.xdk.geolocation.watchPosition(successFunction,errorFunction,options);

Description

Use this command rather than the getCurrentLocation command to track progress during a trip rather than just getting a single position. This command asynchronously acquires the latitude and longitude of the device. When data is available, the success function is called. If there is an error getting position data, the error function is called.

Available Platforms

  • Apple iOS
  • Google Android
  • Microsoft Windows 8 - BETA
  • Microsoft Windows Phone 8 - BETA

Parameters

  • successFunction: When data is available, this success function is called.
  • errorFunction: If there is an error getting position data, the error function is called.
  • options: Some options may be specified for the method as an array object.
Option Possible Values Use
timeout (an integer) The number of milliseconds between checks of position rather than the default value of 10000 (or ten seconds).
enableHighAccuracy True This will force the command to report back a more accurate latitude and longitude position at the expense of more battery usage.
maximumAge (an integer) The number of milliseconds the command will wait before deciding that it cannot get a new position reading and instead run the error message.

Example

//This array holds the options for the command
var options = {timeout: 10000, maximumAge: 11000, enableHighAccuracy: true };

//This function is called on every iteration of the watch Position command that 
//fails
var fail = function(){
  alert("Geolocation failed. \nPlease enable GPS in Settings.");
};

//This function is called on every iteration of the watchPosition command that 
// is a success
var suc = function(p){
  alert("Moved To: Latitude:" + p.coords.latitude + "Longitude:" + 
    p.coords.longitude);
};

//This command starts watching the geolocation
var geolocationWatchTimer = 
    intel.xdk.geolocation.watchPosition(suc,fail,options);

//Call the stopGeolocation function to stop the geolocation watch
var stopGeolocation = function(){
        intel.xdk.geolocation.clearWatch(geolocationWatchTimer);
}