Add options to ol.Geolocation constructor
This commit is contained in:
@@ -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
|
||||
|
||||
+15
-3
@@ -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
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user