Skip to content

Commit

Permalink
Add options to ol.Geolocation constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Apr 20, 2013
1 parent 945d2f6 commit be7228f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/objectliterals.jsdoc
@@ -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.
* @typedef {Object} ol.MapOptions
Expand Down
18 changes: 15 additions & 3 deletions src/ol/geolocation.js
Expand Up @@ -33,11 +33,14 @@ ol.GeolocationProperty = {
/**
* @constructor
* @extends {ol.Object}
* @param {ol.GeolocationOptions=} opt_options Options.
*/
ol.Geolocation = function() {
ol.Geolocation = function(opt_options) {

goog.base(this);

var options = goog.isDef(opt_options) ? opt_options : {};

/**
* The unprojected (EPSG:4326) device position.
* @private
Expand All @@ -51,14 +54,23 @@ ol.Geolocation = function() {
*/
this.watchId_ = undefined;

this.setTracking(false);

goog.events.listen(
this, ol.Object.getChangedEventType(ol.GeolocationProperty.PROJECTION),
this.handleProjectionChanged_, false, this);
goog.events.listen(
this, ol.Object.getChangedEventType(ol.GeolocationProperty.TRACKING),
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);

Expand Down

0 comments on commit be7228f

Please sign in to comment.