You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
[Android] Incorrect Anchor when reusing MarkerViewOptions #5421
I'm experiencing "moving" Markers because the Anchor of a MarkerView seems faulty when reusing once set MarkerViewOptions when the map orientation changes, e.g. while using the locationtracking/bearingtracking
The MarkerView (here they are the location pins) stays at a stable position, it works when i constantly set up new MarkerViewOptions for adding a MarkerView.
Actual behavior
In this example the anchor is completly wrong and it is moving. The clips are quite short but you can take the lake or street as reference. I assume the true anchor point does not really change and just sticks with the initial one when setting up new MarkerViewOptions().
So for example if you want to reuse MarkerViewOptions, maybe for multiple locations that only differ in their coordinates you would always have to set up new MarkerViewOptions. I haven't tested yet whether this also affects the visibility option that would usually be the better practice than constantly recreating MarkerViews.
Is it correct that the view and marker model used for Tower indicator is the same as the actual Tower marker?
If yes, could you validate proposed solution below?
By looking at current anchor implementation:
/** * Specifies the anchor being set on a particular point point of the MarkerView. * <p> * The anchor point is specified in the continuous space [0.0, 1.0] x [0.0, 1.0], where (0, 0) * is the top-left corner of the image, and (1, 1) is the bottom-right corner. * </p> * * @param u u-coordinate of the anchor, as a ratio of the image width (in the range [0, 1]) * @param v v-coordinate of the anchor, as a ratio of the image height (in the range [0, 1]) */publicvoidsetAnchor(@FloatRange(from = 0.0, to = 1.0) floatu, @FloatRange(from = 0.0, to = 1.0) floatv) {
this.anchorU = u;
this.anchorV = v;
}
You can see the values are set but aren't updated right away. The only time these are update is in the MarkerViewManager.update() method. This is the place where we do the actual x,y offset calculation. Once set these aren't updated anymore since the update() method is called on each draw.
@Schumi09 Thanks for the feedback. We have now proposed a fix for this via #5459. This should be available for you test in the SNAPSHOT later today and in 4.1.0 next week. Please reopen the ticket if the problem persists.
Activity
tobrun commentedon Jun 23, 2016
@Schumi09 thank you for the detailed report.
Tower indicatoris the same as the actualTower marker?By looking at current anchor implementation:
You can see the values are set but aren't updated right away. The only time these are update is in the
MarkerViewManager.update()method. This is the place where we do the actual x,y offset calculation. Once set these aren't updated anymore since theupdate()method is called on each draw.I'm currently thinking of setting
offsetXandoffsetYto -1 when the setter of anchor is called. This will result in recalculating the related values.[android] Recalculate offset with new anchor
zugaldia commentedon Jun 23, 2016
@Schumi09 Thanks for the feedback. We have now proposed a fix for this via #5459. This should be available for you test in the
SNAPSHOTlater today and in4.1.0next week. Please reopen the ticket if the problem persists.shiyuankao commentedon Jul 8, 2016
convertView.getMeasuredWidth() Gets the value of 0