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

Add className and style prop to the MapControl component #379

Open
devnaumov opened this issue May 22, 2024 · 1 comment
Open

Add className and style prop to the MapControl component #379

devnaumov opened this issue May 22, 2024 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@devnaumov
Copy link

Target Use Case

Currently, the MapControl component does not support applying custom styles or classes, which limits its flexibility. We need the ability to add className and style props to this component to allow for custom styling. For example, we want to make the control take 100% of the container by using inset: 0px 0px auto 0px;

Proposal

Modify the MapControl component to accept className and style props.

@usefulthink
Copy link
Collaborator

Since the MapControl component is using the same portal logic that is used by AdvancedMarker or InfoWindows, this could be implemented in much the same way:

// update className and styles of marker.content element
usePropBinding(contentContainer, 'className', className ?? '');
useEffect(() => {
if (!contentContainer) return;
setValueForStyles(contentContainer, style || null, prevStyleRef.current);
prevStyleRef.current = style || null;
}, [contentContainer, className, style]);

However, I'm not sure this would be especially useful given how the controls are meant to be used: They implement a layouting algorithm to allow for multiple independent controls to co-exist within a map-instance, partially overlaid on the map. If the element should have the full width of the container it would be easier to just add it as a sibling of Map-component.

@usefulthink usefulthink added enhancement New feature or request good first issue Good for newcomers labels Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants