Skip to content

Fixed Annotations HitTesting & Added annotation anchor v2#38

Closed
iakov-kaiumov wants to merge 19 commits intopauljohanneskraft:mainfrom
iakov-kaiumov:main
Closed

Fixed Annotations HitTesting & Added annotation anchor v2#38
iakov-kaiumov wants to merge 19 commits intopauljohanneskraft:mainfrom
iakov-kaiumov:main

Conversation

@iakov-kaiumov
Copy link
Copy Markdown

UPD: I reopen #35. I removed directions implementation and returned WatchOS 6.0 support.

This pull request implements several fixes and enchantments:

  1. Clickable SwiftUI Annotations! Handle annotation selection #4

  2. Added anchor parameter to the ViewMapAnnotation similar to the default SwiftUI Map approach.

  3. Fixed annotations centering problem MapAnnotations not centered properly #14. Thanks to @rderimay (I took solution from Integrated proposed code to center MapAnnotations properly #25

self.invalidateIntrinsicContentSize()

if let anchor = mapAnnotation.anchor {
centerOffset = .init(x: anchor.x * intrinsicContentFrame.width / 2, y: anchor.y * intrinsicContentFrame.height / 2)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On iOS 16 you can just assign anchorPoint rather than calculating the centerOffset

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why, but anchorPoint does not really work in this case... I guess it may happen because of some size issues.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

@allenhumphreys
Copy link
Copy Markdown

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.

@allenhumphreys
Copy link
Copy Markdown

@iakov-kaiumov Here's what I had come up with on this front: https://github.com/pauljohanneskraft/Map/pull/40/files

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants