Based on OpenLayers.Control.Measure
, the DynamicMeasure control shows
measurements on labels that follow the cursor. This avoids having to worry
about preparing a DOM item to display measurements.
The control also has preset styles to show lines and labels, so the only thing to do is add it to the map.
Control allows displaying lengths and headings of the segments that form a polyline or a polygon.
- measure-dynamic.html (adapted from "measure.html" OpenLayers example)
Example:
...
// to mesure length
var cMeasure = new OpenLayers.Control.DynamicMeasure(OpenLayers.Handler.Path);
map.addControl(cMeasure);
...
// ... and to start measuring
cMeasure.activate();
...
// ... and to stop it
cMeasure.deactivate();
...
This control is now adapted to handle the methods undo redo and cancel of drawing handlers.
See the example measure-dynamic-dev.html (allows choose whether to use the patch posted on OL-Ragbag)
The control can use it as a DrawFeature
control, see example measure-and-draw.html
Measure annotations are shown for the current measurement by default. They can be keeped for all measures using the keep
property, see example measure-and-keep.html
- API for users
- For developers
The DynamicMeasure
control works correctly with release 2.11 or higher
including the development version.
According Yus's question in DEV
some adjustments are made to solve some problems:
labels do not remain at the end of measure,
using the freehand the map is dirtied by the labels,
layer of the labels (vlayer
) should be on top of the drawing layer,
allow use of immediate measure (new in 2.11)