@@ -112,6 +112,8 @@ class LocationModel {
112112
113113 // If deactivating, cleanup
114114 if ( active === false ) {
115+ // Lets cleanup the flash animating, so we don't get multiple animations.
116+ clearInterval ( this . flashInterval ) ;
115117 // Remove features from map if tracking has been switched off
116118 this . layer . getSource ( ) . clear ( ) ;
117119 // Make sure that we zoom to location next time tracking is activated
@@ -124,13 +126,13 @@ class LocationModel {
124126 this . layer . getSource ( ) . addFeature ( this . positionFeature ) ;
125127
126128 // Finally, start flashing the position feature
127- setInterval ( ( ) => {
129+ this . flashInterval = setInterval ( ( ) => {
128130 this . flash ( this . positionFeature ) ;
129131 } , 3000 ) ;
130132 }
131133 } ;
132134
133- // Flash handler: sets up the animation and creats a handler for the postrender
135+ // Flash handler: sets up the animation and creates a handler for the postrender
134136 flash = ( feature ) => {
135137 // Helper: takes care of the actual animation.
136138 const animate = ( event ) => {
@@ -176,6 +178,8 @@ class LocationModel {
176178 const flashGeom = feature . getGeometry ( ) . clone ( ) ;
177179 // Save the listener key so we can unsubscribe when animation is done
178180 const listenerKey = this . layer . on ( "postrender" , animate ) ;
181+ // We need to force render, otherwise postrender won't run the first time.
182+ this . map . render ( ) ;
179183 } ;
180184
181185 enable ( ) {
0 commit comments