Fixed Annotations HitTesting & Added annotation anchor v2#38
Fixed Annotations HitTesting & Added annotation anchor v2#38iakov-kaiumov wants to merge 19 commits intopauljohanneskraft:mainfrom
Conversation
| self.invalidateIntrinsicContentSize() | ||
|
|
||
| if let anchor = mapAnnotation.anchor { | ||
| centerOffset = .init(x: anchor.x * intrinsicContentFrame.width / 2, y: anchor.y * intrinsicContentFrame.height / 2) |
There was a problem hiding this comment.
On iOS 16 you can just assign anchorPoint rather than calculating the centerOffset
There was a problem hiding this comment.
I don't know why, but anchorPoint does not really work in this case... I guess it may happen because of some size issues.
There was a problem hiding this comment.
I noticed another issue with anchorPoint - in the original implementation, the default anchorPoint is at (0.5, 0.5) whereas your implementation seems to use (0.0, 0.0) as default - could you please change that according to the original implementation to not cause confusion?
There was a problem hiding this comment.
@pauljohanneskraft
Thank you for your response!
I changed my implementation according to the original SwiftUI version. Now, default anchorPoint is at (0.5, 0.5). Also, I renamed the anchor parameter to the anchorPoint as in original version.
|
I have some findings I'd like to share on the front of keeping the frames the way they're supposed to be that might provide some insights for your ongoing investigation here @iakov-kaiumov . With my solution, anchorPoint works as expected. I'm going to try to create a branch to show what I'd propose. |
|
@iakov-kaiumov Here's what I had come up with on this front: https://github.com/pauljohanneskraft/Map/pull/40/files |
UPD: I reopen #35. I removed directions implementation and returned WatchOS 6.0 support.
This pull request implements several fixes and enchantments:
Clickable SwiftUI Annotations! Handle annotation selection #4
Added anchor parameter to the ViewMapAnnotation similar to the default SwiftUI Map approach.
Fixed annotations centering problem MapAnnotations not centered properly #14. Thanks to @rderimay (I took solution from Integrated proposed code to center MapAnnotations properly #25