Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Return calibration points together with map #423
Return calibration points together with map #423
Changes from 2 commits
6616a10
9e11681
a76299f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is these changed needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the SVG image has no size it makes it difficult (or impossible) for the Vacuum Map card to translate the vacuum coordinates back to the map after the image gets scaled again in the Home Assistant UI.
For example in my case the viewport size is 229x237, but Chrome reports the naturalWidth/naturalHeight as 145x150. I believe height is always 150 and width is proportional. Firefox returns 0 for both naturalWidth and naturalHeight. The viewport size is not readily available.
However, if we set the width and height explicitly for the SVG then its available as naturalWidth/naturalHeight and the coordinate mapping works correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not set a width or height, as the front end should decide how big it should be drawn.
The problem with setting a width/height on an SVG is that the frontend will use it for showing. For that reason, we use the viewport.
More info about this topic can be found in home-assistant/core#98036 (comment)
We are calculating the calibration points against the viewport and it's the card's job to apply the difference between the viewport and the actual width/height which the card decided to display.
@PiotrMachowski How much work is it to calculate the position of the object according to the viewport if an SVG only has a viewport and no width/height?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edenhaus I haven't tried using the map card with SVG yet, I'll have to check it out.