Using the OpenLayers Measure exemple (http://openlayers.org/en/v3.10.1/examples/measure.html), I'm trying to have only a single measure active at a time.
http://jsfiddle.net/Sinnel/yfdejpre/1/
However, the static measure results appear in a overlay and I have not been able to limit/delete old measures from staying on the map. I have tried different approaches for quite some time, the one giving the "best" results being :
if (map.getOverlays().getArray().length >= 2) {
map.getOverlays().clear()};
However, the result is quite inconsistent…
How should I approach this?
Best Answer
check this fiddle. click Its your fiddle with slight mods to do your job.