title: Changing Style of the icon using ol3 (Openlayers 3)
body: <p>I am adding markers and changing its position using the <code>getFeatureById()</code>. Is there a similar way to update the Style and icon to set the feature without creating it again using <a href="/questions/tagged/openlayers-3" class="post-tag" title="show questions tagged &#39;openlayers-3&#39;" rel="tag">openlayers-3</a>?  </p>
  
  <p>Currently I am doing it this way:</p>
  
  <pre><code>function addArrowMarker(lat, long, angle, pointerimgsrc, arrowFlag) {
  
      iconFeature = new ol.Feature({
          geometry: new ol.geom.Point(ol.proj.transform([+long, +lat], 'EPSG:4326', 'EPSG:3857')),
          name: 'NULL'
      });
  
      iconFeature.setId('arrowMarkerFeature');
  
      iconStyle = new ol.style.Style({
          image: new ol.style.Icon({
              src: pointerimgsrc,
              rotateWithView: true,
              rotation: angle * Math.PI / 180,
              anchor: [.5, .5],
              anchorXUnits: 'fraction', anchorYUnits: 'fraction',
              opacity: 1
          })
      });
  
      iconFeature.setStyle(iconStyle);
  
      vectorArrowSource[arrowFlag] = new ol.source.Vector({
          features: [iconFeature]
      });
  
      vectorArrowLayer[arrowFlag] = new ol.layer.Vector({
          source: vectorArrowSource[arrowFlag]
      });
  
      map.addLayer(vectorArrowLayer[arrowFlag]);
  }
  </code></pre>
  
  <p>Now if there is any change in the angle, then I call the function and set a new style again as shown below.</p>
  
  <pre><code>function changeArrowMarker(lat, long, angle, pointerimgsrc,arrowFlag) {    
      var myFeature = vectorArrowSource[arrowFlag].getFeatureById('arrowMarkerFeature');
      myFeature.getGeometry().setCoordinates(ol.proj.transform([+long, +lat], 'EPSG:4326', 'EPSG:3857'));
  
      iconStyle = new ol.style.Style({
          image: new ol.style.Icon({
              src: pointerimgsrc,
              rotateWithView: true,
              rotation: angle * Math.PI / 180,
              anchor: [.5, .5],
              anchorXUnits: 'fraction', anchorYUnits: 'fraction',
              opacity: 1
          })
      });
  
      myFeature.setStyle(iconStyle);
  }
  </code></pre>
  
  <p>I there any better approach that . Please help!!</p>