-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
feat: add isHighAccurate property to Marker #11136
Conversation
883f479
to
816c4b0
Compare
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.
Thanks for the contribution @malekym!
One small piece of feedback so far: I don't think isHighAccurate
is the most descriptive name for this property. Perhaps snapToPixel
would give a more clear description of the behavior?
I think this should close #8614, but this will need to be verified. |
@SnailBones |
@SnailBones Also can we have it on |
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.
Can you say what your use case is for this? It seems like a very small, subtle change and I'm not sure it justifies expanding the API with a new option and two new methods
Nevermind. I see that this is in response to #11135
@ryanhamley As @malekeym describes in #11135, the use case is to create smoother animated markers. The current jitter is demonstrated in this demo. I wonder if there's a way to address this without expanding the API - perhaps specifically disabling snapping on recently-moved markers? |
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.
Thanks for taking this on @malekeym. Besides the comments I left, this also needs to add snapToPixel
(or whatever it ends up being called) to the documentation by adding it as a @param
in the options documentation in lines 33-47. We should also be able to add some unit tests that compare the marker's position with and without this new property being set to ensure we're getting the expected outcome.
*/ | ||
setSnapToPixel(shouldSnapToPixel: boolean) { | ||
this._snapToPixel = shouldSnapToPixel; | ||
return this; |
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 want to call this._update()
after updating snapToPixel
as in all the other setter methods. We should also handle the undefined condition here: this._snapToPixel = !!shouldSnapToPixel;
.
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.
Done!
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.
@ryanbaumann
I think calling _update
when changing snapToPixel
is redundant because _pos
doesn't change so if call _update
nothing changed. Am I right? let me know to remove calling _update
on setSnapToPixel
.
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.
I think that setSnapToPixel(true)
should update the position so that the snap can be immediately perceived by the user.
In line 536, we can adjust it from |
That would disable snapping on Ideally, I think we want the Marker to snap on discrete position changes or when it finishes moving, but not during ongoing animations. I don't see any easy way to do that automatically without adding an extra @malekeym @ryanhamley As an alternative to a class property, what about an optional argument to |
Maybe use an optional parameter in
Is it clear? Do you think it's a good idea? |
5b04c53
to
336dd54
Compare
Good point @malekeym! One option would be to avoid updating Does that make sense? What do you think? |
I catch you, you mean to split |
@SnailBones with merging this #11167 I close this PR, Thank you! |
Add
isHighAccurate
property toMarker
. for disable roundingmarker._pos
close #11135
Launch Checklist
@mapbox/map-design-team
@mapbox/static-apis
if this PR includes style spec API or visual changes@mapbox/gl-native
if this PR includes shader changes or needs a native portmapbox-gl-js
changelog:<changelog></changelog>