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

MGLAnnotationView not update location immediately on setCoordinate: #5230

Closed
Gerz-inc opened this issue Jun 3, 2016 · 7 comments
Closed
Assignees
Labels
annotations Annotations on iOS and macOS or markers on Android bug iOS Mapbox Maps SDK for iOS
Milestone

Comments

@Gerz-inc
Copy link

Gerz-inc commented Jun 3, 2016

Platform: iOS
Mapbox SDK version: 3.3 alpha-3

Steps to trigger behavior

  1. [annotation setCoordinate:CLLocationCoordinate2DMake(...,...)];

Expected behavior

Updating position of MGLAnnotationView on map view

Actual behavior

Position changing only if map region changed, other annotations added or other manipulations with map

@1ec5
Copy link
Contributor

1ec5 commented Jun 3, 2016

At one point, I think this code was getting lucky and causing all annotations to be redrawn, including view-backed annotations. But we should add something explicit here to update the annotation views.

/cc @boundsj

@1ec5 1ec5 added bug iOS Mapbox Maps SDK for iOS annotations Annotations on iOS and macOS or markers on Android labels Jun 3, 2016
@1ec5 1ec5 added this to the ios-v3.3.0 milestone Jun 3, 2016
@1ec5
Copy link
Contributor

1ec5 commented Jun 5, 2016

Actually, I’m seeing a somewhat different bug. The iosapp demo application is configured so that tapping on an annotation’s callout view changes the annotation’s coordinates to the screen center. But if I remove the (otherwise unused) implementation of -[MGLMapViewDelegate imageForAnnotation:], when tapping a view-backed annotation’s callout, an annotation image (with the default red pin image) also appears at the screen center in addition to the annotation view:

centered

@1ec5 1ec5 self-assigned this Jun 5, 2016
1ec5 added a commit that referenced this issue Jun 6, 2016
We don’t normally want an annotation view to animate its position, because that makes the view appear to lag behind the map. But when the annotation view moves due to the underlying annotation model object moving, the developer may want exactly that effect.

This change continues to disable the default implicit bounds (and now position) animation. It also groups the view updates in -updateAnnotationViews in a transaction that disables animation actions, to improve perceived performance with a large number of annotations. However, when the annotation model object changes, we move the annotation view outside of that transaction to allow the developer to opt into animation.

If the developer moreover wants the annotation view to animate even due to the viewport changing, they can override -setCenter: to use a UIView animation block.

Fixes #5230.
1ec5 added a commit that referenced this issue Jun 8, 2016
We don’t normally want an annotation view to animate its position, because that makes the view appear to lag behind the map. But when the annotation view moves due to the underlying annotation model object moving, the developer may want exactly that effect.

This change continues to disable the default implicit bounds (and now position) animation. It also groups the view updates in -updateAnnotationViews in a transaction that disables animation actions, to improve perceived performance with a large number of annotations. However, when the annotation model object changes, we move the annotation view outside of that transaction to allow the developer to opt into animation.

If the developer moreover wants the annotation view to animate even due to the viewport changing, they can override -setCenter: to use a UIView animation block.

Fixes #5230.
@1ec5
Copy link
Contributor

1ec5 commented Jun 20, 2016

#5245 would fix this issue for sure by introducing an explicit update of the annotation view in response to the KVO change notification.

1ec5 added a commit that referenced this issue Jun 24, 2016
We don’t normally want an annotation view to animate its position, because that makes the view appear to lag behind the map. But when the annotation view moves due to the underlying annotation model object moving, the developer may want exactly that effect.

This change continues to disable the default implicit bounds (and now position) animation. It also groups the view updates in -updateAnnotationViews in a transaction that disables animation actions, to improve perceived performance with a large number of annotations. However, when the annotation model object changes, we move the annotation view outside of that transaction to allow the developer to opt into animation.

If the developer moreover wants the annotation view to animate even due to the viewport changing, they can override -setCenter: to use a UIView animation block.

Fixes #5230.
1ec5 added a commit that referenced this issue Jul 3, 2016
We don’t normally want an annotation view to animate its position, because that makes the view appear to lag behind the map. But when the annotation view moves due to the underlying annotation model object moving, the developer may want exactly that effect.

This change continues to disable the default implicit bounds (and now position) animation. It also groups the view updates in -updateAnnotationViews in a transaction that disables animation actions, to improve perceived performance with a large number of annotations. However, when the annotation model object changes, we move the annotation view outside of that transaction to allow the developer to opt into animation.

If the developer moreover wants the annotation view to animate even due to the viewport changing, they can override -setCenter: to use a UIView animation block.

Fixes #5230.
@1ec5
Copy link
Contributor

1ec5 commented Jul 3, 2016

Fixed in #5550, which will be in v3.3.0-beta.3 shortly.

@1ec5 1ec5 closed this as completed Jul 3, 2016
@Gerz-inc
Copy link
Author

Gerz-inc commented Aug 1, 2016

I tested on version 3.3.3, no change. The marker position are updated immediately only if to move the map, or after few seconds
11

@1ec5
Copy link
Contributor

1ec5 commented Aug 1, 2016

That sounds similar to the issue described in #5755 (comment).

@prgorasiya
Copy link

@Gerz-inc Could you provide the sample code for the animated car movement animation as I am unable to achieve the same results for my project?
Thanks

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 bug iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

No branches or pull requests

3 participants