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

Annotations are not selected when map is rotated #15082

Closed

Description

@cbo1964

If you add an Annotation (MGLPointAnnotation) then when the map is rotated the Annotation is not selected (in fact not found by the "- (MGLAnnotationTag)annotationTagAtPoint:(CGPoint)point persistingResults:(BOOL)persist").

Steps to reproduce

  1. Using the demo App
  2. Make a long press gesture and add a pin
  3. Tap on the pin with map not rotated, it is detected and selected ("- (BOOL)mapView:(__unused MGLMapView *)mapView annotationCanShowCallout:(__unused id )annotation" is called)
  4. rotate the map (90# is fine but seems not so important)
  5. tap on the pin and the pin it is NOT detected

Expected behavior

I expect that the same Annotation is found in "any map conditions": rotated, tilted.

Actual behavior

The MGLPointAnnotations are not detected when the map is rotated

Configuration

Mapbox SDK versions: 5.1.0
iOS/macOS versions: iOS 12.3.1
Device/simulator models: iPad Pro
Xcode version: 10.2.1

Activity

  1. added
    iOS
    on Jul 9, 2019
  2. julianrex commented on Jul 9, 2019

    @julianrex
    Contributor

    Thanks for your feedback @cbo1964.

    Our documentation here is misleading and currently slightly inaccurate: See MGLCalloutView.dismissesAutomatically - it states

    A Boolean value indicating whether the callout view should be dismissed automatically

    This should read whether the annotation is automatically deselected (and in the process dismisses the callout).

    Please try implementing dismissesAutomatically so that it returns NO to see if that solves your issue. Also...

    Note that a single tap on the map view still dismisses the callout view regardless of the value of this property.

    Leaving this issue open as a documentation task and potential feature improvement.

  3. cbo1964 commented on Jul 9, 2019

    @cbo1964
    Author

    Hi,
    maybe I was not able to preperly explain the issue but I think there is a misunderstanding.

    The problem is the detection of the MGLAnnotation when you tap (and not the callout).
    What I mean is that the

    • (MGLAnnotationTag)annotationTagAtPoint:(CGPoint)point persistingResults:(BOOL)persist
      function in the MGLMapView, when calling the
      std::vector nearbyAnnotations = [self annotationTagsInRect:queryRect];
      does not find any annotation under the tap if the map is rotated, whereas the same function, with the same data found the annotation if the map it is not rotated (rotated using the 2 finger rotation gesture).

    Moreover, I was having other problems with the Annotation and I'm debugging a little bit the code and I found something that I'm not sure it is related with above issue: if you zoom (with pinch) at zoom levels that are not perfectly aligned (not an integer value) annotations are also not found.
    What I have seen is that in the
    std::pair<bool,bool> CollisionIndex::placeFeature(CollisionFeature& feature, ...

    function, the calculated projected point
    const auto projectedPoint = projectAndGetPerspectiveRatio(posMatrix, box.anchor);
    is wrong (sensibly wrong) when you are in this "in between zoom",

    Maybe there is something I'm doing wrong (highly probable because I'm not expert in Mapbox) but I worked in the past with RouteMe and Mapnik and other libraries like these and I cannot understand what I'm doing wrong.

    Thanks

  4. julianrex commented on Jul 9, 2019

    @julianrex
    Contributor

    Thanks for the clarification @cbo1964!

  5. cbo1964 commented on Jul 10, 2019

    @cbo1964
    Author

    I think this problem is the same than #14977

  6. julianrex commented on Jul 12, 2019

    @julianrex
    Contributor

    PR for this issue: #15097

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationfeatureiOS

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions