Private enum for geolocation properties

This commit is contained in:
Tim Schaub
2016-12-27 13:24:02 -07:00
parent a303b2f6b0
commit f748245e3d

View File

@@ -65,10 +65,10 @@ ol.Geolocation = function(opt_options) {
this.watchId_ = undefined; this.watchId_ = undefined;
ol.events.listen( ol.events.listen(
this, ol.Object.getChangeEventType(ol.Geolocation.Property.PROJECTION), this, ol.Object.getChangeEventType(ol.Geolocation.Property_.PROJECTION),
this.handleProjectionChanged_, this); this.handleProjectionChanged_, this);
ol.events.listen( ol.events.listen(
this, ol.Object.getChangeEventType(ol.Geolocation.Property.TRACKING), this, ol.Object.getChangeEventType(ol.Geolocation.Property_.TRACKING),
this.handleTrackingChanged_, this); this.handleTrackingChanged_, this);
if (options.projection !== undefined) { if (options.projection !== undefined) {
@@ -103,7 +103,7 @@ ol.Geolocation.prototype.handleProjectionChanged_ = function() {
ol.proj.get('EPSG:4326'), projection); ol.proj.get('EPSG:4326'), projection);
if (this.position_) { if (this.position_) {
this.set( this.set(
ol.Geolocation.Property.POSITION, this.transform_(this.position_)); ol.Geolocation.Property_.POSITION, this.transform_(this.position_));
} }
} }
}; };
@@ -134,13 +134,13 @@ ol.Geolocation.prototype.handleTrackingChanged_ = function() {
*/ */
ol.Geolocation.prototype.positionChange_ = function(position) { ol.Geolocation.prototype.positionChange_ = function(position) {
var coords = position.coords; var coords = position.coords;
this.set(ol.Geolocation.Property.ACCURACY, coords.accuracy); this.set(ol.Geolocation.Property_.ACCURACY, coords.accuracy);
this.set(ol.Geolocation.Property.ALTITUDE, this.set(ol.Geolocation.Property_.ALTITUDE,
coords.altitude === null ? undefined : coords.altitude); coords.altitude === null ? undefined : coords.altitude);
this.set(ol.Geolocation.Property.ALTITUDE_ACCURACY, this.set(ol.Geolocation.Property_.ALTITUDE_ACCURACY,
coords.altitudeAccuracy === null ? coords.altitudeAccuracy === null ?
undefined : coords.altitudeAccuracy); undefined : coords.altitudeAccuracy);
this.set(ol.Geolocation.Property.HEADING, coords.heading === null ? this.set(ol.Geolocation.Property_.HEADING, coords.heading === null ?
undefined : ol.math.toRadians(coords.heading)); undefined : ol.math.toRadians(coords.heading));
if (!this.position_) { if (!this.position_) {
this.position_ = [coords.longitude, coords.latitude]; this.position_ = [coords.longitude, coords.latitude];
@@ -149,13 +149,13 @@ ol.Geolocation.prototype.positionChange_ = function(position) {
this.position_[1] = coords.latitude; this.position_[1] = coords.latitude;
} }
var projectedPosition = this.transform_(this.position_); var projectedPosition = this.transform_(this.position_);
this.set(ol.Geolocation.Property.POSITION, projectedPosition); this.set(ol.Geolocation.Property_.POSITION, projectedPosition);
this.set(ol.Geolocation.Property.SPEED, this.set(ol.Geolocation.Property_.SPEED,
coords.speed === null ? undefined : coords.speed); coords.speed === null ? undefined : coords.speed);
var geometry = ol.geom.Polygon.circular( var geometry = ol.geom.Polygon.circular(
ol.sphere.WGS84, this.position_, coords.accuracy); ol.sphere.WGS84, this.position_, coords.accuracy);
geometry.applyTransform(this.transform_); geometry.applyTransform(this.transform_);
this.set(ol.Geolocation.Property.ACCURACY_GEOMETRY, geometry); this.set(ol.Geolocation.Property_.ACCURACY_GEOMETRY, geometry);
this.changed(); this.changed();
}; };
@@ -185,7 +185,7 @@ ol.Geolocation.prototype.positionError_ = function(error) {
*/ */
ol.Geolocation.prototype.getAccuracy = function() { ol.Geolocation.prototype.getAccuracy = function() {
return /** @type {number|undefined} */ ( return /** @type {number|undefined} */ (
this.get(ol.Geolocation.Property.ACCURACY)); this.get(ol.Geolocation.Property_.ACCURACY));
}; };
@@ -197,7 +197,7 @@ ol.Geolocation.prototype.getAccuracy = function() {
*/ */
ol.Geolocation.prototype.getAccuracyGeometry = function() { ol.Geolocation.prototype.getAccuracyGeometry = function() {
return /** @type {?ol.geom.Geometry} */ ( return /** @type {?ol.geom.Geometry} */ (
this.get(ol.Geolocation.Property.ACCURACY_GEOMETRY) || null); this.get(ol.Geolocation.Property_.ACCURACY_GEOMETRY) || null);
}; };
@@ -210,7 +210,7 @@ ol.Geolocation.prototype.getAccuracyGeometry = function() {
*/ */
ol.Geolocation.prototype.getAltitude = function() { ol.Geolocation.prototype.getAltitude = function() {
return /** @type {number|undefined} */ ( return /** @type {number|undefined} */ (
this.get(ol.Geolocation.Property.ALTITUDE)); this.get(ol.Geolocation.Property_.ALTITUDE));
}; };
@@ -223,7 +223,7 @@ ol.Geolocation.prototype.getAltitude = function() {
*/ */
ol.Geolocation.prototype.getAltitudeAccuracy = function() { ol.Geolocation.prototype.getAltitudeAccuracy = function() {
return /** @type {number|undefined} */ ( return /** @type {number|undefined} */ (
this.get(ol.Geolocation.Property.ALTITUDE_ACCURACY)); this.get(ol.Geolocation.Property_.ALTITUDE_ACCURACY));
}; };
@@ -235,7 +235,7 @@ ol.Geolocation.prototype.getAltitudeAccuracy = function() {
*/ */
ol.Geolocation.prototype.getHeading = function() { ol.Geolocation.prototype.getHeading = function() {
return /** @type {number|undefined} */ ( return /** @type {number|undefined} */ (
this.get(ol.Geolocation.Property.HEADING)); this.get(ol.Geolocation.Property_.HEADING));
}; };
@@ -248,7 +248,7 @@ ol.Geolocation.prototype.getHeading = function() {
*/ */
ol.Geolocation.prototype.getPosition = function() { ol.Geolocation.prototype.getPosition = function() {
return /** @type {ol.Coordinate|undefined} */ ( return /** @type {ol.Coordinate|undefined} */ (
this.get(ol.Geolocation.Property.POSITION)); this.get(ol.Geolocation.Property_.POSITION));
}; };
@@ -261,7 +261,7 @@ ol.Geolocation.prototype.getPosition = function() {
*/ */
ol.Geolocation.prototype.getProjection = function() { ol.Geolocation.prototype.getProjection = function() {
return /** @type {ol.proj.Projection|undefined} */ ( return /** @type {ol.proj.Projection|undefined} */ (
this.get(ol.Geolocation.Property.PROJECTION)); this.get(ol.Geolocation.Property_.PROJECTION));
}; };
@@ -274,7 +274,7 @@ ol.Geolocation.prototype.getProjection = function() {
*/ */
ol.Geolocation.prototype.getSpeed = function() { ol.Geolocation.prototype.getSpeed = function() {
return /** @type {number|undefined} */ ( return /** @type {number|undefined} */ (
this.get(ol.Geolocation.Property.SPEED)); this.get(ol.Geolocation.Property_.SPEED));
}; };
@@ -286,7 +286,7 @@ ol.Geolocation.prototype.getSpeed = function() {
*/ */
ol.Geolocation.prototype.getTracking = function() { ol.Geolocation.prototype.getTracking = function() {
return /** @type {boolean} */ ( return /** @type {boolean} */ (
this.get(ol.Geolocation.Property.TRACKING)); this.get(ol.Geolocation.Property_.TRACKING));
}; };
@@ -301,7 +301,7 @@ ol.Geolocation.prototype.getTracking = function() {
*/ */
ol.Geolocation.prototype.getTrackingOptions = function() { ol.Geolocation.prototype.getTrackingOptions = function() {
return /** @type {GeolocationPositionOptions|undefined} */ ( return /** @type {GeolocationPositionOptions|undefined} */ (
this.get(ol.Geolocation.Property.TRACKING_OPTIONS)); this.get(ol.Geolocation.Property_.TRACKING_OPTIONS));
}; };
@@ -313,7 +313,7 @@ ol.Geolocation.prototype.getTrackingOptions = function() {
* @api stable * @api stable
*/ */
ol.Geolocation.prototype.setProjection = function(projection) { ol.Geolocation.prototype.setProjection = function(projection) {
this.set(ol.Geolocation.Property.PROJECTION, projection); this.set(ol.Geolocation.Property_.PROJECTION, projection);
}; };
@@ -324,7 +324,7 @@ ol.Geolocation.prototype.setProjection = function(projection) {
* @api stable * @api stable
*/ */
ol.Geolocation.prototype.setTracking = function(tracking) { ol.Geolocation.prototype.setTracking = function(tracking) {
this.set(ol.Geolocation.Property.TRACKING, tracking); this.set(ol.Geolocation.Property_.TRACKING, tracking);
}; };
@@ -338,14 +338,15 @@ ol.Geolocation.prototype.setTracking = function(tracking) {
* @api stable * @api stable
*/ */
ol.Geolocation.prototype.setTrackingOptions = function(options) { ol.Geolocation.prototype.setTrackingOptions = function(options) {
this.set(ol.Geolocation.Property.TRACKING_OPTIONS, options); this.set(ol.Geolocation.Property_.TRACKING_OPTIONS, options);
}; };
/** /**
* @enum {string} * @enum {string}
* @private
*/ */
ol.Geolocation.Property = { ol.Geolocation.Property_ = {
ACCURACY: 'accuracy', ACCURACY: 'accuracy',
ACCURACY_GEOMETRY: 'accuracyGeometry', ACCURACY_GEOMETRY: 'accuracyGeometry',
ALTITUDE: 'altitude', ALTITUDE: 'altitude',