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 button to location-selector to move marker to current view #22198

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

karwosts
Copy link
Contributor

@karwosts karwosts commented Oct 2, 2024

Proposed change

Add an icon-button to ha-selector-location which drops the marker at the center of the current viewport.

This is much faster than the old method (which I find very cumbersome), where you have to:

  • zoom out so you can see the current marker location and target location
  • drag the marker to the roughly desired area
  • zoom in
  • refine marker location
  • repeat zoom/refine

image

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue or discussion:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

This comment was marked as off-topic.

@MindFreeze MindFreeze added the Needs UX Pull requests requiring a review from the Home Assistant design team label Oct 29, 2024
@MindFreeze
Copy link
Contributor

Thanks for bringing this up. The team discussed this and we decided a better UX would be to move the marker on single press. So you tap/click the map anywhere to place the marker there. Obviously this shouldn't interfere with panning the map or resizing the circle.
Are you interested in implementing this @karwosts ?

@MindFreeze MindFreeze removed the Needs UX Pull requests requiring a review from the Home Assistant design team label Oct 30, 2024
@karwosts
Copy link
Contributor Author

I poked at this for a bit but so far I've been unsuccessful in figuring out how to generate a click event on the base map. I may come back to it to try again sometime but I'm not sure.

Right now the map shows the grab cursor on hover, would it be changed to the pointer cursor instead?

@MindFreeze
Copy link
Contributor

Right now the map shows the grab cursor on hover, would it be changed to the pointer cursor instead?

@matthiasdebaat what do you think?

@karwosts karwosts added the help-wanted In need of Additional Help label Oct 30, 2024
@matthiasdebaat
Copy link
Collaborator

Right now the map shows the grab cursor on hover, would it be changed to the pointer cursor instead?

Yes, I think this is needed to make this interaction work. On drag it should switch to the grab cursor.

We have to check if this also works on mobile. Alternative for touch interfaces could be to have the marker in a fixed center position of the map, allowing users to drag the map underneath instead of dragging the marker itself.

@wendevlin
Copy link
Contributor

Hi @karwosts,

you can add event listeners to the leaflet map object in ha-map.ts: https://leafletjs.com/reference.html#map-click

this.leafletMap.on("click", () => { fireEvent(this, "click") })

then you can handle the click somewhere.
And leaflet will handle that it's not a drag or something else.

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

Successfully merging this pull request may close these issues.

4 participants