Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

[ios, macos] Fix an issue that triggers didSelectAnnotations#10538

Merged
fabian-guerra merged 2 commits into
release-aguafrom
fabian-didselect-annotation-10523
Nov 30, 2017
Merged

[ios, macos] Fix an issue that triggers didSelectAnnotations#10538
fabian-guerra merged 2 commits into
release-aguafrom
fabian-didselect-annotation-10523

Conversation

@fabian-guerra
Copy link
Copy Markdown
Contributor

Fixes #10523

@fabian-guerra fabian-guerra added the annotations Annotations on iOS and macOS or markers on Android label Nov 22, 2017
@fabian-guerra fabian-guerra added this to the ios-v3.7.1 milestone Nov 22, 2017
@fabian-guerra fabian-guerra self-assigned this Nov 22, 2017
@friedbunny
Copy link
Copy Markdown
Contributor

@fabian-guerra Could you explain why this change is necessary and how it’s fixing the issue? 🙇

@fabian-guerra
Copy link
Copy Markdown
Contributor Author

fabian-guerra commented Nov 23, 2017

@friedbunny in #9984 we added select/deselect support to shape annotations. Later in #10262 we made shape annotations part of the iterable annotations. The problem is since all annotations are a subclass of MGLShape it was bypassing the filtering for image based annotations. Instead of filtering the annotation using the following code:

annotationRect = [self frameOfImage:annotationImage.image ?: fallbackImage centeredAtCoordinate:annotation.coordinate];

It was falling into:

if ([annotation isKindOfClass:[MGLShape class]])

I added this code to avoid filtering shape annotations. Since are filtered here:

- (std::vector<MGLAnnotationTag>)shapeAnnotationTagsInRect:(CGRect)rect
{
return _rendererFrontend->getRenderer()->queryShapeAnnotations({
{ CGRectGetMinX(rect), CGRectGetMinY(rect) },
{ CGRectGetMaxX(rect), CGRectGetMaxY(rect) },
});
}

Image based annotations avoided getting filtered by using the image CGRect thus triggering the didSelectAnnotation method. The fix uses MGLMultiPoint to verify for shape annotations.

@kkaefer kkaefer added iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS labels Nov 24, 2017
@fabian-guerra
Copy link
Copy Markdown
Contributor Author

@friedbunny I added more context. Please let me know if something is still not clear.

Copy link
Copy Markdown
Contributor

@friedbunny friedbunny left a comment

Choose a reason for hiding this comment

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

Thanks for the explanation. ❤️

@fabian-guerra fabian-guerra force-pushed the fabian-didselect-annotation-10523 branch from a344713 to f7587f3 Compare November 28, 2017 21:03
@fabian-guerra fabian-guerra force-pushed the fabian-didselect-annotation-10523 branch from f7587f3 to e5dcf5e Compare November 30, 2017 18:09
@fabian-guerra fabian-guerra merged commit 06a0c03 into release-agua Nov 30, 2017
@fabian-guerra fabian-guerra deleted the fabian-didselect-annotation-10523 branch November 30, 2017 19:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

annotations Annotations on iOS and macOS or markers on Android iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants