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);
}
cordova plugin add https://github.com/OutSystems/Cordova-Plugin-Cache-Coordinates.git
- Android
The CacheCoordinates
object provides a way to init the tracker to get the coordinates, get coordinates and stop the tracker.
-
init: Start tracker the coordinates.
-
getCoordinates: Return the last coordinates.
-
stop: Stop tracker to get Coordinates.
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)
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);
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)
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"
}"
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)
var success = function (r) {
console.log("Response = " + r);
}
var fail = function (error) {
console.log("init error " + error);
}
cordova.plugins.cacheCoordinates.stop(success, fail)
- OutSystems - Mobility Experts
- João Gonçalves, joao.goncalves@outsystems.com
- Rúben Gonçalves, ruben.goncalves@outsystems.com
- Vitor Oliveira, vitor.oliveira@outsystems.com
- Vitor Oliveira, vitor.oliveira@outsystems.com
###Copyright OutSystems, 2015
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.