mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 23:25:11 +08:00
1d79b6617b
I did my best to clean up the JavaScript so it would pass through jsHint more cleanly. There still are issues but there are a lot fewer now. This helped to make the JS code more consistent.
90 lines
2.0 KiB
JavaScript
Executable File
90 lines
2.0 KiB
JavaScript
Executable File
/*
|
|
* PhoneGap is available under *either* the terms of the modified BSD license *or* the
|
|
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
|
|
*
|
|
* Copyright (c) 2005-2010, Nitobi Software Inc.
|
|
* Copyright (c) 2010-2011, IBM Corporation
|
|
*/
|
|
|
|
if (!PhoneGap.hasResource("position")) {
|
|
PhoneGap.addResource("position");
|
|
|
|
/**
|
|
* This class contains position information.
|
|
* @param {Object} lat
|
|
* @param {Object} lng
|
|
* @param {Object} acc
|
|
* @param {Object} alt
|
|
* @param {Object} altacc
|
|
* @param {Object} head
|
|
* @param {Object} vel
|
|
* @constructor
|
|
*/
|
|
var Position = function(coords, timestamp) {
|
|
this.coords = coords;
|
|
this.timestamp = (timestamp !== 'undefined') ? timestamp : new Date().getTime();
|
|
};
|
|
|
|
/** @constructor */
|
|
var Coordinates = function(lat, lng, alt, acc, head, vel, altacc) {
|
|
/**
|
|
* The latitude of the position.
|
|
*/
|
|
this.latitude = lat;
|
|
/**
|
|
* The longitude of the position,
|
|
*/
|
|
this.longitude = lng;
|
|
/**
|
|
* The accuracy of the position.
|
|
*/
|
|
this.accuracy = acc;
|
|
/**
|
|
* The altitude of the position.
|
|
*/
|
|
this.altitude = alt;
|
|
/**
|
|
* The direction the device is moving at the position.
|
|
*/
|
|
this.heading = head;
|
|
/**
|
|
* The velocity with which the device is moving at the position.
|
|
*/
|
|
this.speed = vel;
|
|
/**
|
|
* The altitude accuracy of the position.
|
|
*/
|
|
this.altitudeAccuracy = (altacc !== 'undefined') ? altacc : null;
|
|
};
|
|
|
|
/**
|
|
* This class specifies the options for requesting position data.
|
|
* @constructor
|
|
*/
|
|
var PositionOptions = function() {
|
|
/**
|
|
* Specifies the desired position accuracy.
|
|
*/
|
|
this.enableHighAccuracy = true;
|
|
/**
|
|
* The timeout after which if position data cannot be obtained the errorCallback
|
|
* is called.
|
|
*/
|
|
this.timeout = 10000;
|
|
};
|
|
|
|
/**
|
|
* This class contains information about any GSP errors.
|
|
* @constructor
|
|
*/
|
|
var PositionError = function() {
|
|
this.code = null;
|
|
this.message = "";
|
|
};
|
|
|
|
PositionError.UNKNOWN_ERROR = 0;
|
|
PositionError.PERMISSION_DENIED = 1;
|
|
PositionError.POSITION_UNAVAILABLE = 2;
|
|
PositionError.TIMEOUT = 3;
|
|
}
|