OpenLayers 3 move marker on slider value change

المشرف العام

Administrator
طاقم الإدارة
I am trying to use slider to animate openlayers marker move. It should be similar to this example http://openlayers.org/en/v3.12.1/examples/feature-move-animation.html but the only difference is that I dont want marker to move automatically (through animation) but on slider value change.

Slider represents something like timeline of current route. I am using following code to acomplis it:

dateSlider.noUiSlider.on('update', function( values) { var date = new Date(+values); points_array.forEach(function(entry) { if(dateString(date) == entry['time']){ geoMarker.setGeometry = new ol.geom.Point([parseFloat(entry['lon']), parseFloat(entry['lat'])]); geoMarker.getGeometry().transform('EPSG:4326', 'EPSG:3857'); map.render(); } });});first problem is that slider step is one second and it is too much load to iterate through all array values so the geometry set event is fired only when I move slider very slowly. However this is not actual problem because I can fix this by using a bit different approach. But the problem is that when I try to set new geometry everything from vectorLayer (it contains route + all icons and marker) dissapears.

So what is the correct way to update feature location without making whole layer dissapear?

Thanks in forward



أكثر...
 
أعلى