diff --git a/src/ol/geolocation.js b/src/ol/geolocation.js index 8888726c9c..2df407fa9b 100644 --- a/src/ol/geolocation.js +++ b/src/ol/geolocation.js @@ -4,6 +4,7 @@ goog.provide('ol.Geolocation'); goog.require('ol'); goog.require('ol.Object'); +goog.require('ol.GeolocationProperty'); goog.require('ol.events'); goog.require('ol.events.EventType'); goog.require('ol.geom.Polygon'); @@ -65,10 +66,10 @@ ol.Geolocation = function(opt_options) { this.watchId_ = undefined; ol.events.listen( - this, ol.Object.getChangeEventType(ol.Geolocation.Property_.PROJECTION), + this, ol.Object.getChangeEventType(ol.GeolocationProperty.PROJECTION), this.handleProjectionChanged_, this); ol.events.listen( - this, ol.Object.getChangeEventType(ol.Geolocation.Property_.TRACKING), + this, ol.Object.getChangeEventType(ol.GeolocationProperty.TRACKING), this.handleTrackingChanged_, this); if (options.projection !== undefined) { @@ -103,7 +104,7 @@ ol.Geolocation.prototype.handleProjectionChanged_ = function() { ol.proj.get('EPSG:4326'), projection); if (this.position_) { this.set( - ol.Geolocation.Property_.POSITION, this.transform_(this.position_)); + ol.GeolocationProperty.POSITION, this.transform_(this.position_)); } } }; @@ -134,13 +135,13 @@ ol.Geolocation.prototype.handleTrackingChanged_ = function() { */ ol.Geolocation.prototype.positionChange_ = function(position) { var coords = position.coords; - this.set(ol.Geolocation.Property_.ACCURACY, coords.accuracy); - this.set(ol.Geolocation.Property_.ALTITUDE, + this.set(ol.GeolocationProperty.ACCURACY, coords.accuracy); + this.set(ol.GeolocationProperty.ALTITUDE, coords.altitude === null ? undefined : coords.altitude); - this.set(ol.Geolocation.Property_.ALTITUDE_ACCURACY, + this.set(ol.GeolocationProperty.ALTITUDE_ACCURACY, coords.altitudeAccuracy === null ? undefined : coords.altitudeAccuracy); - this.set(ol.Geolocation.Property_.HEADING, coords.heading === null ? + this.set(ol.GeolocationProperty.HEADING, coords.heading === null ? undefined : ol.math.toRadians(coords.heading)); if (!this.position_) { this.position_ = [coords.longitude, coords.latitude]; @@ -149,13 +150,13 @@ ol.Geolocation.prototype.positionChange_ = function(position) { this.position_[1] = coords.latitude; } var projectedPosition = this.transform_(this.position_); - this.set(ol.Geolocation.Property_.POSITION, projectedPosition); - this.set(ol.Geolocation.Property_.SPEED, + this.set(ol.GeolocationProperty.POSITION, projectedPosition); + this.set(ol.GeolocationProperty.SPEED, coords.speed === null ? undefined : coords.speed); var geometry = ol.geom.Polygon.circular( ol.sphere.WGS84, this.position_, coords.accuracy); geometry.applyTransform(this.transform_); - this.set(ol.Geolocation.Property_.ACCURACY_GEOMETRY, geometry); + this.set(ol.GeolocationProperty.ACCURACY_GEOMETRY, geometry); this.changed(); }; @@ -185,7 +186,7 @@ ol.Geolocation.prototype.positionError_ = function(error) { */ ol.Geolocation.prototype.getAccuracy = function() { return /** @type {number|undefined} */ ( - this.get(ol.Geolocation.Property_.ACCURACY)); + this.get(ol.GeolocationProperty.ACCURACY)); }; @@ -197,7 +198,7 @@ ol.Geolocation.prototype.getAccuracy = function() { */ ol.Geolocation.prototype.getAccuracyGeometry = function() { return /** @type {?ol.geom.Geometry} */ ( - this.get(ol.Geolocation.Property_.ACCURACY_GEOMETRY) || null); + this.get(ol.GeolocationProperty.ACCURACY_GEOMETRY) || null); }; @@ -210,7 +211,7 @@ ol.Geolocation.prototype.getAccuracyGeometry = function() { */ ol.Geolocation.prototype.getAltitude = function() { return /** @type {number|undefined} */ ( - this.get(ol.Geolocation.Property_.ALTITUDE)); + this.get(ol.GeolocationProperty.ALTITUDE)); }; @@ -223,7 +224,7 @@ ol.Geolocation.prototype.getAltitude = function() { */ ol.Geolocation.prototype.getAltitudeAccuracy = function() { return /** @type {number|undefined} */ ( - this.get(ol.Geolocation.Property_.ALTITUDE_ACCURACY)); + this.get(ol.GeolocationProperty.ALTITUDE_ACCURACY)); }; @@ -235,7 +236,7 @@ ol.Geolocation.prototype.getAltitudeAccuracy = function() { */ ol.Geolocation.prototype.getHeading = function() { return /** @type {number|undefined} */ ( - this.get(ol.Geolocation.Property_.HEADING)); + this.get(ol.GeolocationProperty.HEADING)); }; @@ -248,7 +249,7 @@ ol.Geolocation.prototype.getHeading = function() { */ ol.Geolocation.prototype.getPosition = function() { return /** @type {ol.Coordinate|undefined} */ ( - this.get(ol.Geolocation.Property_.POSITION)); + this.get(ol.GeolocationProperty.POSITION)); }; @@ -261,7 +262,7 @@ ol.Geolocation.prototype.getPosition = function() { */ ol.Geolocation.prototype.getProjection = function() { return /** @type {ol.proj.Projection|undefined} */ ( - this.get(ol.Geolocation.Property_.PROJECTION)); + this.get(ol.GeolocationProperty.PROJECTION)); }; @@ -274,7 +275,7 @@ ol.Geolocation.prototype.getProjection = function() { */ ol.Geolocation.prototype.getSpeed = function() { return /** @type {number|undefined} */ ( - this.get(ol.Geolocation.Property_.SPEED)); + this.get(ol.GeolocationProperty.SPEED)); }; @@ -286,7 +287,7 @@ ol.Geolocation.prototype.getSpeed = function() { */ ol.Geolocation.prototype.getTracking = function() { return /** @type {boolean} */ ( - this.get(ol.Geolocation.Property_.TRACKING)); + this.get(ol.GeolocationProperty.TRACKING)); }; @@ -301,7 +302,7 @@ ol.Geolocation.prototype.getTracking = function() { */ ol.Geolocation.prototype.getTrackingOptions = function() { return /** @type {GeolocationPositionOptions|undefined} */ ( - this.get(ol.Geolocation.Property_.TRACKING_OPTIONS)); + this.get(ol.GeolocationProperty.TRACKING_OPTIONS)); }; @@ -313,7 +314,7 @@ ol.Geolocation.prototype.getTrackingOptions = function() { * @api stable */ ol.Geolocation.prototype.setProjection = function(projection) { - this.set(ol.Geolocation.Property_.PROJECTION, projection); + this.set(ol.GeolocationProperty.PROJECTION, projection); }; @@ -324,7 +325,7 @@ ol.Geolocation.prototype.setProjection = function(projection) { * @api stable */ ol.Geolocation.prototype.setTracking = function(tracking) { - this.set(ol.Geolocation.Property_.TRACKING, tracking); + this.set(ol.GeolocationProperty.TRACKING, tracking); }; @@ -338,23 +339,5 @@ ol.Geolocation.prototype.setTracking = function(tracking) { * @api stable */ ol.Geolocation.prototype.setTrackingOptions = function(options) { - this.set(ol.Geolocation.Property_.TRACKING_OPTIONS, options); -}; - - -/** - * @enum {string} - * @private - */ -ol.Geolocation.Property_ = { - ACCURACY: 'accuracy', - ACCURACY_GEOMETRY: 'accuracyGeometry', - ALTITUDE: 'altitude', - ALTITUDE_ACCURACY: 'altitudeAccuracy', - HEADING: 'heading', - POSITION: 'position', - PROJECTION: 'projection', - SPEED: 'speed', - TRACKING: 'tracking', - TRACKING_OPTIONS: 'trackingOptions' + this.set(ol.GeolocationProperty.TRACKING_OPTIONS, options); }; diff --git a/src/ol/geolocationproperty.js b/src/ol/geolocationproperty.js new file mode 100644 index 0000000000..08017cf714 --- /dev/null +++ b/src/ol/geolocationproperty.js @@ -0,0 +1,18 @@ +goog.provide('ol.GeolocationProperty'); + + +/** + * @enum {string} + */ +ol.GeolocationProperty = { + ACCURACY: 'accuracy', + ACCURACY_GEOMETRY: 'accuracyGeometry', + ALTITUDE: 'altitude', + ALTITUDE_ACCURACY: 'altitudeAccuracy', + HEADING: 'heading', + POSITION: 'position', + PROJECTION: 'projection', + SPEED: 'speed', + TRACKING: 'tracking', + TRACKING_OPTIONS: 'trackingOptions' +}; diff --git a/src/ol/interaction/draw.js b/src/ol/interaction/draw.js index 129c0d08d7..d359ee8f77 100644 --- a/src/ol/interaction/draw.js +++ b/src/ol/interaction/draw.js @@ -18,6 +18,7 @@ goog.require('ol.geom.MultiPoint'); goog.require('ol.geom.MultiPolygon'); goog.require('ol.geom.Point'); goog.require('ol.geom.Polygon'); +goog.require('ol.interaction.DrawEventType'); goog.require('ol.interaction.Pointer'); goog.require('ol.interaction.Property'); goog.require('ol.layer.Vector'); @@ -483,7 +484,7 @@ ol.interaction.Draw.prototype.startDrawing_ = function(event) { this.sketchFeature_.setGeometry(geometry); this.updateSketchFeatures_(); this.dispatchEvent(new ol.interaction.Draw.Event( - ol.interaction.Draw.EventType_.DRAWSTART, this.sketchFeature_)); + ol.interaction.DrawEventType.DRAWSTART, this.sketchFeature_)); }; @@ -609,7 +610,7 @@ ol.interaction.Draw.prototype.removeLastPoint = function() { /** * Stop drawing and add the sketch feature to the target layer. - * The {@link ol.interaction.Draw.EventType_.DRAWEND} event is dispatched before + * The {@link ol.interaction.DrawEventType.DRAWEND} event is dispatched before * inserting the feature. * @api */ @@ -639,7 +640,7 @@ ol.interaction.Draw.prototype.finishDrawing = function() { // First dispatch event to allow full set up of feature this.dispatchEvent(new ol.interaction.Draw.Event( - ol.interaction.Draw.EventType_.DRAWEND, sketchFeature)); + ol.interaction.DrawEventType.DRAWEND, sketchFeature)); // Then insert feature if (this.features_) { @@ -686,7 +687,7 @@ ol.interaction.Draw.prototype.extend = function(feature) { this.sketchCoords_.push(last.slice()); this.updateSketchFeatures_(); this.dispatchEvent(new ol.interaction.Draw.Event( - ol.interaction.Draw.EventType_.DRAWSTART, this.sketchFeature_)); + ol.interaction.DrawEventType.DRAWSTART, this.sketchFeature_)); }; @@ -842,7 +843,7 @@ ol.interaction.Draw.Mode_ = { * @constructor * @extends {ol.events.Event} * @implements {oli.DrawEvent} - * @param {ol.interaction.Draw.EventType_} type Type. + * @param {ol.interaction.DrawEventType} type Type. * @param {ol.Feature} feature The feature drawn. */ ol.interaction.Draw.Event = function(type, feature) { @@ -858,23 +859,3 @@ ol.interaction.Draw.Event = function(type, feature) { }; ol.inherits(ol.interaction.Draw.Event, ol.events.Event); - - -/** - * @enum {string} - * @private - */ -ol.interaction.Draw.EventType_ = { - /** - * Triggered upon feature draw start - * @event ol.interaction.Draw.Event#drawstart - * @api stable - */ - DRAWSTART: 'drawstart', - /** - * Triggered upon feature draw end - * @event ol.interaction.Draw.Event#drawend - * @api stable - */ - DRAWEND: 'drawend' -}; diff --git a/src/ol/interaction/draweventtype.js b/src/ol/interaction/draweventtype.js new file mode 100644 index 0000000000..bc533b31f7 --- /dev/null +++ b/src/ol/interaction/draweventtype.js @@ -0,0 +1,20 @@ +goog.provide('ol.interaction.DrawEventType'); + + +/** + * @enum {string} + */ +ol.interaction.DrawEventType = { + /** + * Triggered upon feature draw start + * @event ol.interaction.Draw.Event#drawstart + * @api stable + */ + DRAWSTART: 'drawstart', + /** + * Triggered upon feature draw end + * @event ol.interaction.Draw.Event#drawend + * @api stable + */ + DRAWEND: 'drawend' +}; diff --git a/src/ol/interaction/modify.js b/src/ol/interaction/modify.js index 0e8f954f25..3dd9283619 100644 --- a/src/ol/interaction/modify.js +++ b/src/ol/interaction/modify.js @@ -15,6 +15,7 @@ goog.require('ol.events.condition'); goog.require('ol.extent'); goog.require('ol.geom.GeometryType'); goog.require('ol.geom.Point'); +goog.require('ol.interaction.ModifyEventType'); goog.require('ol.interaction.Pointer'); goog.require('ol.layer.Vector'); goog.require('ol.source.Vector'); @@ -214,7 +215,7 @@ ol.interaction.Modify.prototype.willModifyFeatures_ = function(evt) { if (!this.modified_) { this.modified_ = true; this.dispatchEvent(new ol.interaction.Modify.Event( - ol.interaction.Modify.EventType_.MODIFYSTART, this.features_, evt)); + ol.interaction.ModifyEventType.MODIFYSTART, this.features_, evt)); } }; @@ -633,7 +634,7 @@ ol.interaction.Modify.handleUpEvent_ = function(evt) { } if (this.modified_) { this.dispatchEvent(new ol.interaction.Modify.Event( - ol.interaction.Modify.EventType_.MODIFYEND, this.features_, evt)); + ol.interaction.ModifyEventType.MODIFYEND, this.features_, evt)); this.modified_ = false; } return false; @@ -828,7 +829,7 @@ ol.interaction.Modify.prototype.removePoint = function() { this.willModifyFeatures_(evt); this.removeVertex_(); this.dispatchEvent(new ol.interaction.Modify.Event( - ol.interaction.Modify.EventType_.MODIFYEND, this.features_, evt)); + ol.interaction.ModifyEventType.MODIFYEND, this.features_, evt)); this.modified_ = false; return true; } @@ -1004,7 +1005,7 @@ ol.interaction.Modify.getDefaultStyleFunction = function() { * @constructor * @extends {ol.events.Event} * @implements {oli.ModifyEvent} - * @param {ol.interaction.Modify.EventType_} type Type. + * @param {ol.interaction.ModifyEventType} type Type. * @param {ol.Collection.