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.

Changing coordinate of custom class conforming to MGLAnnotation does not move annotation on map #5720

Closed

Description

@charliecliff

If I call:
[self.locationAnnotation setCoordinate:((MDRLocationCondition *)self.condition).location.coordinate];

I expect that method to be KVO Compliant, as you guys said it is. But it ain't...

Platform:
Mapbox SDK version:

Steps to trigger behavior

  1. Add an MGLPointAnnotation to the Map
  2. Change it's Coordinate Property
    3.

Expected behavior

The MGLPointAnnotation Should Move.

Actual behavior

The MGLPointAnnotation does not Move.

Activity

  1. 1ec5 commented on Jul 19, 2016

    @1ec5
    Contributor

    What version of the SDK are you using?

    Also, is locationAnnotation an instance of MGLPointAnnotation or is it an instance of a subclass of MGLPointAnnotation? (Be sure to verify that it's the type you expect at runtime.) MGLPointAnnotation itself does have a KVO-compliant implementation, but it's possible for a subclass to have a non-compliant implementation.

  2. added
    iOS
    on Jul 19, 2016
  3. Gerz-inc commented on Aug 1, 2016

    @Gerz-inc

    @charliecliff I have the same problem as you have won it?

  4. reopened this on Aug 1, 2016
  5. 1ec5 commented on Aug 1, 2016

    @1ec5
    Contributor

    Via #5755, there are also reports of the annotation image also failing to update. (Both the image and coordinate are updated via the same mechanism.)

  6. added
    annotations
    on Aug 1, 2016
  7. ChrisXu commented on Oct 1, 2016

    @ChrisXu

    It's also not working for me.

    class Annotation: NSObject, MGLAnnotation {
    ...
    }

    The workaround is to subclass by MGLPointAnnotation, then it's working now.

    class Annotation: MGLPointAnnotation {
    ...
    }
  8. changed the title [-]MGLMapView Still does not update the Annotation when the Coordinate property of the Annotation is changed.[/-] [+]Changing coordinate of custom class conforming to MGLAnnotation does not move annotation on map[/+] on Oct 1, 2016
  9. Gerz-inc commented on Jan 16, 2017

    @Gerz-inc

    @1ec5

    class Annotation: MGLPointAnnotation {
        @property (nonatomic, assign) CLLocationCoordinate2D position;
        @property (nonatomic, assign) CLLocationCoordinate2D positionPrev;
    ...
    }
    
    @implementation Annotation
    
    - (void)setPosition:(CLLocationCoordinate2D)coord {
        [super setCoordinate:coord];
        positionPrev = self.position;
        position = coord;
    }
    

    That's configuration not update annotation immediately. Maybe you can help?

  10. Gerz-inc commented on Jan 16, 2017

    @Gerz-inc

    @1ec5
    [self setCoordinate:coord];
    Helped me

  11. 1ec5 commented on Jan 17, 2017

    @1ec5
    Contributor

    I’m unable to reproduce this problem in iOS SDK v3.4.0-beta.7 or macOS SDK v0.3.0-rc.1. I tried setting the coordinate property of an instance of MGLPointAnnotation, an instance of a subclass of MGLPointAnnotation, and an instance of a subclass of NSObject that conforms to MGLAnnotation. In all three scenarios, the annotation correctly moves on both iOS and macOS.

    @Gerz-inc, I don’t see any issues with the code that you’ve posted, but have you verified that the -setPosition: setter you’ve implemented gets called at the expected times?

  12. added
    archived
    on Nov 15, 2018
  13. stale commented on Nov 24, 2018

    @stale

    This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

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

    annotationsarchivediOS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions