Skip to content

OutSystems/Cordova-Plugin-Cache-Coordinates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cordova Cache Coordinates Plugin

This plugin allows you to get coordinates and store them to return quickly one result when there is a request. The main goal with this plugin is for the situations that the device can lose the GPS signal and for this case return the last coordinates captured.

Although in the global scope, they are not available until after the deviceready event.

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    console.log(FileTransfer);
}

Installation

cordova plugin add https://github.com/OutSystems/Cordova-Plugin-Cache-Coordinates.git

Supported Platforms

  • Android

CacheCoordinates

The CacheCoordinates object provides a way to init the tracker to get the coordinates, get coordinates and stop the tracker.

Methods

  • init: Start tracker the coordinates.

  • getCoordinates: Return the last coordinates.

  • stop: Stop tracker to get Coordinates.

init

Parameters:

  • timeBetweenUpdates: The minimum time interval between location updates, in milliseconds.

  • metersBetweenUpdates: The minimum distance between location updates in meters.

  • successCallback: A callback that is passed a CacheCoordinates object. (Function)

  • errorCallback: A callback that executes if an error occurs retrieving the CacheCoordinates object. (Function)

Example

var success = function (r) {
    console.log("Response = " + r);
}

var fail = function (error) {
    console.log("init error " + error);
}

var timeBetweenUpdates = 120000; // 2min
var metersBetweenUpdates = 100;

cordova.plugins.cacheCoordinates.init(success, fail, timeBetweenUpdates, metersBetweenUpdates);

getCoordinates

Parameters:

  • successCallback: A callback that is passed a CacheCoordinates object. (Function)

  • errorCallback: A callback that executes if an error occurs retrieving the CacheCoordinates object. (Function)

Example

var success = function (r) {
    console.log("Response = " + r);
}

var fail = function (error) {
    console.log("coordinates error " + error);
}

cordova.plugins.cacheCoordinates.getCoordinates(success, fail);

Sample Response: 
"{
    timestamp: "2015-08-04 08:04:03.759", 
    longitude: "-19.5333", 
    latitude: "45.96670000000001"
}"

stop

Parameters:

  • successCallback: A callback that is passed a CacheCoordinates object. (Function)

  • errorCallback: A callback that executes if an error occurs retrieving the CacheCoordinates object. (Function)

Example

var success = function (r) {
    console.log("Response = " + r);
}

var fail = function (error) {
    console.log("init error " + error);
}

cordova.plugins.cacheCoordinates.stop(success, fail)

Contributors

Document author

###Copyright OutSystems, 2015


LICENSE

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.