[GIS] Removing measure label from OpenLayers 3 measure

javascriptopenlayers

I have implemented the measure example available on the OpenLayers 3 site (http://openlayers.org/en/v3.11.2/examples/measure.html) and I am currently trying to include a clear button that will clear both the drawn area / line and label from the map.

I've found the getSource().clear() option will clear the drawn shape from the map, but I am struggling to work out how I can clear the measurement label?

I have tried the map.removeOverlay() method with 'measureTooltip' but this doesn't work.

How can I also remove this label from the map?

Best Answer

I guess you use jquery. if so do the following to remove the tooltips from map:

$( ".tooltip" ).remove();

this should remove every element with class 'tooltip' from document. check this fiddle it is from an older question. Within the fiddle the code snip adove is asigned when drawstart event occurs, because thats the way user wanted to be. You may place it within your function that clears the measures