I
I
Ilya Alekseev2016-08-12 22:47:56
JavaScript
Ilya Alekseev, 2016-08-12 22:47:56

How to hide/show line in openlayers?

There are two lines, you need to complete one when the condition is met and hide the second, when the other condition is met, show the second one back.
The beginning is -

var vectorSource = new ol.source.Vector();
      var vectorLayer = new ol.layer.Vector({ source: vectorSource });
      var drawLine = new ol.interaction.Draw({
          source: vectorSource,
          type: 'LineString'
      });


      var vectorSourceHide = new ol.source.Vector();
      var vectorLayerHide = new ol.layer.Vector({ source: vectorSourceHide });
      var drawLineHide = new ol.interaction.Draw({
          source: vectorSourceHide,
          type: 'LineString'
      });


      map.addLayer(vectorLayer);
      map.addLayer(vectorLayerHide);

and then in conditions -
if(true)
{
 drawLine.finishDrawing();
//скрыть вторую линию
}

if (false)
{
 //показать обратно вторую линию
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question