perliedman / leaflet-realtime

Put realtime data on a Leaflet map
ISC License
743 stars 167 forks source link

How to clear the trail? #172

Closed ghost closed 4 years ago

ghost commented 4 years ago

Please see this SO question

perliedman commented 4 years ago

I posted a reply on SO, but here's a copy of it:

To remove features, the easiest is to just no longer provide those features to the success callback.

So, to remove the trail, you would add some condition under which the trail should no longer be visible and call success like this:

                success({
                    type: 'FeatureCollection',
                    features: [data, trail]
                });

Likewise, if you want to remove the marker as well, call success with empty features:

                success({
                    type: 'FeatureCollection',
                    features: []
                });