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

Fixed Annotations HitTesting & Added annotation anchor v2 #38

Closed
wants to merge 19 commits into from

Conversation

iakov-kaiumov
Copy link

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)

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

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

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

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

None yet

5 participants