Hi I have a question about leaflet marker on angular 5 , the marker value is dynamic and I need to draw just the last result. How can I do it please? is here someone who had the same problem?
var markers; markers = new L.LayerGroup().addTo(myfrugalmap); let timer = TimerObservable.create(0, 10000); this.subscription = timer.subscribe(t => { this.MyService.Localize().subscribe( result => { this.positions = result; let xpo = this.positions.x; let ypo = this.positions.y; let mar=L.marker([xpo,ypo], {icon: greenIcon}) mar.addTo(markers) }); markers.clearLayers(); } )
in result (without (markers.clearLayers)) I have evry 10 second the new position on the map and I need to drop the old positions