Add options to ol.Geolocation constructor

This commit is contained in:
Tom Payne
2013-04-20 16:44:16 +02:00
parent 945d2f6f5d
commit be7228f78e
2 changed files with 22 additions and 3 deletions
+7
View File
@@ -1,3 +1,10 @@
/**
* @typedef {Object} ol.GeolocationOptions
* @property {boolean|undefined} tracking Tracking.
* @property {GeolocationPositionOptions|undefined} trackingOptions Tracking options.
* @property {ol.ProjectionLike} projection Projection.
*/
/** /**
* Object literal with config options for the map. * Object literal with config options for the map.
* @typedef {Object} ol.MapOptions * @typedef {Object} ol.MapOptions
+15 -3
View File
@@ -33,11 +33,14 @@ ol.GeolocationProperty = {
/** /**
* @constructor * @constructor
* @extends {ol.Object} * @extends {ol.Object}
* @param {ol.GeolocationOptions=} opt_options Options.
*/ */
ol.Geolocation = function() { ol.Geolocation = function(opt_options) {
goog.base(this); goog.base(this);
var options = goog.isDef(opt_options) ? opt_options : {};
/** /**
* The unprojected (EPSG:4326) device position. * The unprojected (EPSG:4326) device position.
* @private * @private
@@ -51,14 +54,23 @@ ol.Geolocation = function() {
*/ */
this.watchId_ = undefined; this.watchId_ = undefined;
this.setTracking(false);
goog.events.listen( goog.events.listen(
this, ol.Object.getChangedEventType(ol.GeolocationProperty.PROJECTION), this, ol.Object.getChangedEventType(ol.GeolocationProperty.PROJECTION),
this.handleProjectionChanged_, false, this); this.handleProjectionChanged_, false, this);
goog.events.listen( goog.events.listen(
this, ol.Object.getChangedEventType(ol.GeolocationProperty.TRACKING), this, ol.Object.getChangedEventType(ol.GeolocationProperty.TRACKING),
this.handleTrackingChanged_, false, this); this.handleTrackingChanged_, false, this);
if (goog.isDef(options.projection)) {
this.setProjection(ol.projection.get(options.projection));
}
if (goog.isDef(options.trackingOptions)) {
this.setTrackingOptions(options.trackingOptions);
}
if (goog.isDef(options.tracking)) {
this.setTracking(options.tracking);
}
}; };
goog.inherits(ol.Geolocation, ol.Object); goog.inherits(ol.Geolocation, ol.Object);