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

Allow custom cursors via filename/CSS #13266

Open
jackplo opened this issue Aug 28, 2024 · 1 comment
Open

Allow custom cursors via filename/CSS #13266

jackplo opened this issue Aug 28, 2024 · 1 comment

Comments

@jackplo
Copy link

jackplo commented Aug 28, 2024

Motivation

Custom pointers on layer interactions. I want to be able to change the cursor to a custom .cur/.svg when hovering over different layers on the map. This will allow users to visually identify that certain symbols on the map may have interactive properties.

Design Alternatives

Allow me to use custom CSS classes to overwrite the cursor on mouseover, mouseenter, and mouseleave events or make map.getCanvas().style.cursor able to take custom cursors.

Design

Either design works and both seem minimally invasive to the current functionality of the mapbox cursors. I don't believe there are any drawbacks, I think this is a pretty intuitive feature that would provide significant enhancement to the UI/UX of mapbox.

Mock-Up

Developers:
This could be easy as one line of code for developers. For example in a 'mouseenter' event, a developer could simply set the cursor to a custom .cur/.svg file. Example:

.on('mouseenter', 'LAYERNAME', (evt: any) => {
     this.map.getCanvas().classList.add('CSS CLASS THAT OVERWRITES THE CURSOR');
OR
     this.map.getCanvas().style.cursor = "PATH TO CUSTOM CURSOR LOCATION";
})

End Users:
This would just look like the existing functionality for cursor events but replace it with a custom cursor.

Concepts

This feature could just be an addition to the current wiki page about mouse/cursor events.
I think the terminology could just be "Custom Cursor."
This feature relates to the current cursor functionality associated with mapbox mouse events.
The concept just introduces a new option customization in an intuitive way.

Implementation

For both C++ & Javascript the design implementation would be as simple as the folllowing:

  • Check if assigned string is a valid cursor name or a file
  • If it is valid cursor assign to that cursor
  • If it is a file, verify its a valid filename
  • Verify the file has the proper extension (.svg/.cur)
  • Assign to new cursor value

Edgecases:

  • File does not exist
  • File does not have the proper extension
  • File size too large
  • Cursor height and width are too big
@AryanMankame
Copy link

Hi @stepankuzmin and @jackplo,

I have gone through this repo and came across this issue. I have a query regarding what we are considering to be interactive—specifically, when the cursor should change. Is it when the user hovers over the landmarks, or while zooming in or out? As this repo is not responsible for displaying information about the landmarks, I’d like to clarify this.

Thank you!

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

No branches or pull requests

3 participants