0

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

  • 2
    Please provide more information and/or code samples. Show us what you've tried so far. It is difficult to identify the problem with what you've given. – nipuna-g Jun 17 '18 at 17:31
  • 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(); } ) – YASSIR EL HOUSNI Jun 17 '18 at 17:41
  • in result (without (markers.clearLayers)) I have evry 10 second the new position on the map and I need to drop the old positions – YASSIR EL HOUSNI Jun 17 '18 at 17:44
  • nipuna777 what do you think ? – YASSIR EL HOUSNI Jun 17 '18 at 18:04
  • @YASSIRELHOUSNI Please don't post this in comment, edit your post. – Opsse Jun 17 '18 at 19:29

0 Answers0