alexandra-c / leaflet-tracking-marker

✈ A React Leaflet library that allows developers to create custom markers that drifts to a certain point, computes their bearing angle using given coordinates and rotates accordingly.
MIT License
40 stars 13 forks source link

Problem with KeepAtCenter #28

Closed Dhinesh-Dhinesh closed 2 years ago

Dhinesh-Dhinesh commented 2 years ago

I am trying to toggle keepAtCenter but it's not working, Stucked on the marker position i can't move the map

here is my code:

const [isTracking,setIsTracking] = useState(false)

<LeafletTrackingMarker position={....} icon={....} duration={1000} rotationAngle={...} rotationOrigin="center" keepAtCenter={isTrack}> 
  <Popup>
     Sample Bus Data & Speed:{bus.data.data.speed}
  </Popup>
</LeafletTrackingMarker>

 ..... onClick() {
  setIsTracking((prev)=>!prev)
}
alexandra-c commented 2 years ago

Hello, I'm afraid this is not an issue. The keepAtCenter function works as it is supposed to. As stated in the documentation, this library was inspired from leaflet-drift-marker and react-leaflet-rotatedmarker. You can also check out their documentation examples, I suggest this one here https://codesandbox.io/s/react-leaflet-drift-markerv3-nxzht?fontsize=14&hidenavigation=1&theme=dark&file=/src/index.js , the newer version of leaflet-drift-marker library.