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

Access to label event element #413

Open
shahankit-spotnana opened this issue Jan 6, 2022 · 0 comments
Open

Access to label event element #413

shahankit-spotnana opened this issue Jan 6, 2022 · 0 comments
Labels
triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@shahankit-spotnana
Copy link

shahankit-spotnana commented Jan 6, 2022

Environment details

  1. Specify the API at the beginning of the title (for example, "Places: ...")
  • MarkerWithLabel
  1. OS type and version
  • OSX
  1. Library version and other environment information
  • version: 2.0.0

Steps to reproduce

When updating label content using marker.labelContent setter, entire child element is removed and re-created. This makes it difficult to animate the marker label content. I'm using React.createPortal to update the content of marker.labelContent without un-mounting. As the event div also needs to be updated for mouse and click events to work, it would be great if we can expose the event div as well on marker instance.

Rough demo code

function CustomMarker({ children }) {
  const [mapMarker, setMapMarker] = useState<MarkerWithLabel | null>(null);

  useEffect(() => {
    const labelContentEl = document.createElement('div');
    const marker = new MarkerWithLabel({ labelContent: labelContentEl });
    setMapMarker(marker);
  }, []);

  // This fails because mapMarker.labelContent is string.
  return mapMarker
    ? <>
        {React.createPortal(children, mapMarker.labelElement)}
        {/* Update both event div and content div */}
        {React.createPortal(children, mapMarker.labelEventElement)}
      </>
    : null;
}
@shahankit-spotnana shahankit-spotnana added triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Jan 6, 2022
@jpoehnelt jpoehnelt removed their assignment Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

2 participants