Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotation Angle Zero doesn't work on marker update #24

Closed
FernandoI7 opened this issue Aug 23, 2022 · 1 comment
Closed

Rotation Angle Zero doesn't work on marker update #24

FernandoI7 opened this issue Aug 23, 2022 · 1 comment

Comments

@FernandoI7
Copy link
Contributor

Describe the bug
When a marker is defined with rotationAngle equal to zero, after updating, the marker does not use the zero value and updates the marker angle considering the position variation.

To Reproduce

  1. Setup a marker with rotationAngle={0}
import { useEffect, useState } from "react";
import { LeafletTrackingMarker } from "react-leaflet-tracking-marker/src";
import PropTypes from "prop-types";

const AnimatedMarker = ({ icon, latitude, longitude, children }) => {
  const [prevPos, setPrevPos] = useState([latitude, longitude]);

  useEffect(() => {
    if (prevPos[1] !== longitude && prevPos[0] !== latitude)
      setPrevPos([latitude, longitude]);
  }, [latitude, longitude, prevPos]);

  return (
    <LeafletTrackingMarker
      icon={icon}
      position={[latitude, longitude]}
      duration={1000}
      rotationAngle={0}
      rotationOrigin="unset"
    >
      {children}
    </LeafletTrackingMarker>
  );
};

AnimatedMarker.propTypes = {
  icon: PropTypes.object.isRequired,
  latitude: PropTypes.number.isRequired,
  longitude: PropTypes.number.isRequired,
  children: PropTypes.object.isRequired,
};

export default AnimatedMarker;
  1. Update the marker position

Expected behaviour
Marker must keep zero angle even after marker position update

Screenshots
screencast-localhost_3000-2022 08 23-15_26_28

I already opened a pull request fixing the problem #23

@alexandra-c
Copy link
Owner

Hello, @FernandoI7 ,
I approved and merged your fix, and will create a new release.
Thank you for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants