Merge pull request #871 from marcjansen/measure-api
Measure API enhancements
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
|
OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: events
|
* APIProperty: events
|
||||||
* {<OpenLayers.Events>} Events instance for listeners and triggering
|
* {<OpenLayers.Events>} Events instance for listeners and triggering
|
||||||
* control specific events.
|
* control specific events.
|
||||||
@@ -41,28 +41,28 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
* APIProperty: handlerOptions
|
* APIProperty: handlerOptions
|
||||||
* {Object} Used to set non-default properties on the control's handler
|
* {Object} Used to set non-default properties on the control's handler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: callbacks
|
* Property: callbacks
|
||||||
* {Object} The functions that are sent to the handler for callback
|
* {Object} The functions that are sent to the handler for callback
|
||||||
*/
|
*/
|
||||||
callbacks: null,
|
callbacks: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: displaySystem
|
* APIProperty: displaySystem
|
||||||
* {String} Display system for output measurements. Supported values
|
* {String} Display system for output measurements. Supported values
|
||||||
* are 'english', 'metric', and 'geographic'. Default is 'metric'.
|
* are 'english', 'metric', and 'geographic'. Default is 'metric'.
|
||||||
*/
|
*/
|
||||||
displaySystem: 'metric',
|
displaySystem: 'metric',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: geodesic
|
* APIProperty: geodesic
|
||||||
* {Boolean} Calculate geodesic metrics instead of planar metrics. This
|
* {Boolean} Calculate geodesic metrics instead of planar metrics. This
|
||||||
* requires that geometries can be transformed into Geographic/WGS84
|
* requires that geometries can be transformed into Geographic/WGS84
|
||||||
* (if that is not already the map projection). Default is false.
|
* (if that is not already the map projection). Default is false.
|
||||||
*/
|
*/
|
||||||
geodesic: false,
|
geodesic: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: displaySystemUnits
|
* Property: displaySystemUnits
|
||||||
* {Object} Units for various measurement systems. Values are arrays
|
* {Object} Units for various measurement systems. Values are arrays
|
||||||
@@ -111,10 +111,10 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor: OpenLayers.Control.Measure
|
* Constructor: OpenLayers.Control.Measure
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* handler - {<OpenLayers.Handler>}
|
* handler - {<OpenLayers.Handler>}
|
||||||
* options - {Object}
|
* options - {Object}
|
||||||
*/
|
*/
|
||||||
initialize: function(handler, options) {
|
initialize: function(handler, options) {
|
||||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||||
@@ -125,14 +125,14 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
}
|
}
|
||||||
this.callbacks = OpenLayers.Util.extend(callbacks, this.callbacks);
|
this.callbacks = OpenLayers.Util.extend(callbacks, this.callbacks);
|
||||||
|
|
||||||
// let the handler options override, so old code that passes 'persist'
|
// let the handler options override, so old code that passes 'persist'
|
||||||
// directly to the handler does not need an update
|
// directly to the handler does not need an update
|
||||||
this.handlerOptions = OpenLayers.Util.extend(
|
this.handlerOptions = OpenLayers.Util.extend(
|
||||||
{persist: this.persist}, this.handlerOptions
|
{persist: this.persist}, this.handlerOptions
|
||||||
);
|
);
|
||||||
this.handler = new handler(this, this.callbacks, this.handlerOptions);
|
this.handler = new handler(this, this.callbacks, this.handlerOptions);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: deactivate
|
* APIMethod: deactivate
|
||||||
*/
|
*/
|
||||||
@@ -164,7 +164,7 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
delete this.callbacks.modify;
|
delete this.callbacks.modify;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: updateHandler
|
* Method: updateHandler
|
||||||
*
|
*
|
||||||
@@ -194,7 +194,7 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
this.cancelDelay();
|
this.cancelDelay();
|
||||||
this.measure(geometry, "measure");
|
this.measure(geometry, "measure");
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: measurePartial
|
* Method: measurePartial
|
||||||
* Called each time a new point is added to the measurement sketch.
|
* Called each time a new point is added to the measurement sketch.
|
||||||
@@ -225,9 +225,11 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
/**
|
/**
|
||||||
* Method: measureImmediate
|
* Method: measureImmediate
|
||||||
* Called each time the measurement sketch is modified.
|
* Called each time the measurement sketch is modified.
|
||||||
*
|
*
|
||||||
* Parameters: point - {<OpenLayers.Geometry.Point>} The point at the
|
* Parameters:
|
||||||
* mouseposition. feature - {<OpenLayers.Feature.Vector>} The sketch feature.
|
* point - {<OpenLayers.Geometry.Point>} The point at the mouse position.
|
||||||
|
* feature - {<OpenLayers.Feature.Vector>} The sketch feature.
|
||||||
|
* drawing - {Boolean} Indicates whether we're currently drawing.
|
||||||
*/
|
*/
|
||||||
measureImmediate : function(point, feature, drawing) {
|
measureImmediate : function(point, feature, drawing) {
|
||||||
if (drawing && !this.handler.freehandMode(this.handler.evt)) {
|
if (drawing && !this.handler.freehandMode(this.handler.evt)) {
|
||||||
@@ -270,7 +272,7 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
geometry: geometry
|
geometry: geometry
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: getBestArea
|
* Method: getBestArea
|
||||||
* Based on the <displaySystem> returns the area of a geometry.
|
* Based on the <displaySystem> returns the area of a geometry.
|
||||||
@@ -294,7 +296,7 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
}
|
}
|
||||||
return [area, unit];
|
return [area, unit];
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: getArea
|
* Method: getArea
|
||||||
*
|
*
|
||||||
@@ -321,7 +323,7 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
}
|
}
|
||||||
return area;
|
return area;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: getBestLength
|
* Method: getBestLength
|
||||||
* Based on the <displaySystem> returns the length of a geometry.
|
* Based on the <displaySystem> returns the length of a geometry.
|
||||||
|
|||||||
Reference in New Issue
Block a user