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.
iOS Annotation view sticked at the left of the screen when dragging map #8603
I have a strange behavior on 3.5.0 release for the map with annotations like:
Please also look attached video.
I just drag the map to the left and it appears new annotation from the left side. Before 3.3.4 I did not have such issues. Probably u had similar problem before?
Platform:
iOS 10.2 Mapbox SDK version:
3.5.0
Steps to trigger behavior
Load map with annotations with custom pictures
Drug map to left corner so like annotation will be out of map edge.
Observe the result
Expected behavior
No side effect from dragging and all annotations on the same place.
Hi @evgzor sorry to hear you are having issues with the latest iOS SDK release, if you can provide a code example that help us reproduce the problem, would likely help us solve this issue faster.
changed the title [-]iOS Annotation view sticked at the left of the screen when drugging map[/-][+]iOS Annotation view sticked at the left of the screen when dragging map[/+]on Apr 2, 2017
Hi @fabian-guerra right, I updated from 3.3.4 to 3.5.0 for getting MGLStyle API. However, I observed the same problem on 3.4.2 SDK. Do u still need more info from my side?
Hi @evgzor we have found the issue. When you create a custom MGLAnnotationView you need to set the frame, you can see something because the UIImageView automatically sizes itself to fit the UIImage.
You can fix this by setting the frame e.g annotationView.frame = imageView.frame;
#5469 would simplify this use case by providing an image property that could be set to a UIImage. MGLAnnotationView would add the image and size itself appropriately (the work that is currently being almost done in the example noted here)
@fabian-guerra if I set frame like (0,0,1,1) the issue does not fix and if i set annotationView.frame = imageView.frame; -- I get and it make problem bigger. @boundsj I have implemented own image property for 3.3.4 - and it worked ok till but it works in a little bit different way. I cannot easily use to new approach. It very difficult adopt application when u start to change behavior. From my point of view it's a bug if I cannot use annotation with zero frames (as it was before). You closed it without getting any feedback.
If it's easier for you, ok ...
In 3.4.0, we made some performance improvements to the way annotation views get updated when the map moves. A side effect of the improvements is that we no longer handle this case where the MGLAnnotationView is not large enough to contain its subviews.
We could add logic to the SDK to re-enable support for this by special casing invisible MGLAnnotationViews and always moving them but that would not solve for MGLAnnotationViews that are still visible but smaller than their content. Another option might be to add logic to dig through all of the subviews that an MGLAnnotationView has and determine a sort of sizeThatFits and use that for the view update calculation. However, I'm concerned about introducing another performance degradation by doing that.
I can say that simply using (0,0,1,1) as the frame won't work (although it might if your UIImageView were much smaller).
I'm not sure why setting MGLAnnotationView's width and height to be big enough to contain the UIImageView does not work for you. When I try that with your example it appears to work fine.
Can you please show a code sample where you set the annotation view's width and height to be the same as the image view and say more about why this make the problem worse for you?
Hi @evgzor sorry that #8603 (comment) didn't work for you. Complementing what I said you can use a parent view that fits the UIView subview combined withMGLAnnotationView.centerOffset e.g.
@boundsj and @fabian-guerra for the moment I fixed like that: frame = CGRect(x: 0, y: 0, width: 4, height: 0). and overide centerOffset self.centerOffset = CGVector(dx: self.centerOffset.dx + self.bounds.width / 2 - .... Its workaround, but for complex annotation view which contains several views (not only image view) I have to use that approach. In general it implemented for SDK which can swith between MKMapView and MapBox map, by toggle and I have to always alighn high level api.
I'm trying to implement a custom MGLAnnotationView on iOS with Swift as well. And this issue seems to be continuing even on SDK 3.5.2.
Besides the annotation locations not updating continuously along with the map view, when the map view is initially launched, the annotations appear after a delay of couple of seconds but not immediately.
Activity
fabian-guerra commentedon Mar 31, 2017
Hi @evgzor sorry to hear you are having issues with the latest iOS SDK release, if you can provide a code example that help us reproduce the problem, would likely help us solve this issue faster.
Thank you.
evgzor commentedon Apr 1, 2017
Hi @fabian-guerra I attached code source
AnnotationViewMultipleExample.m.zip from Mapbox example project with simulated problem. Please have a look. If u need full project u may check out from https://github.com/rmnblm/Mapbox-iOS-Examples.git and replace modified file. For reproducing just drag map to the left edge from the scope of annotation region. and u will see the problem.
[-]iOS Annotation view sticked at the left of the screen when drugging map[/-][+]iOS Annotation view sticked at the left of the screen when dragging map[/+]fabian-guerra commentedon Apr 3, 2017
Hi @evgzor thank you for sending an example, I'm able to see the problem. One more question did you updated the SDK from 3.3.4 to 3.5.0?
Thanks again!
evgzor commentedon Apr 3, 2017
Hi @fabian-guerra right, I updated from 3.3.4 to 3.5.0 for getting MGLStyle API. However, I observed the same problem on 3.4.2 SDK. Do u still need more info from my side?
fabian-guerra commentedon Apr 3, 2017
Hi @evgzor we have found the issue. When you create a custom
MGLAnnotationViewyou need to set theframe, you can see something because theUIImageViewautomatically sizes itself to fit theUIImage.You can fix this by setting the frame e.g
annotationView.frame = imageView.frame;/cc @boundsj
boundsj commentedon Apr 3, 2017
#5469 would simplify this use case by providing an
imageproperty that could be set to a UIImage.MGLAnnotationViewwould add the image and size itself appropriately (the work that is currently being almost done in the example noted here)evgzor commentedon Apr 3, 2017
@fabian-guerra if I set frame like (0,0,1,1) the issue does not fix and if i set annotationView.frame = imageView.frame; -- I get
and it make problem bigger.
@boundsj I have implemented own image property for 3.3.4 - and it worked ok till but it works in a little bit different way. I cannot easily use to new approach. It very difficult adopt application when u start to change behavior. From my point of view it's a bug if I cannot use annotation with zero frames (as it was before). You closed it without getting any feedback.
If it's easier for you, ok ...
boundsj commentedon Apr 3, 2017
I'm sorry the workaround in #8603 (comment) did not work for you @evgzor.
In 3.4.0, we made some performance improvements to the way annotation views get updated when the map moves. A side effect of the improvements is that we no longer handle this case where the
MGLAnnotationViewis not large enough to contain its subviews.We could add logic to the SDK to re-enable support for this by special casing invisible
MGLAnnotationViewsand always moving them but that would not solve forMGLAnnotationViewsthat are still visible but smaller than their content. Another option might be to add logic to dig through all of the subviews that anMGLAnnotationViewhas and determine a sort ofsizeThatFitsand use that for the view update calculation. However, I'm concerned about introducing another performance degradation by doing that.I can say that simply using
(0,0,1,1)as the frame won't work (although it might if yourUIImageViewwere much smaller).I'm not sure why setting
MGLAnnotationView's width and height to be big enough to contain theUIImageViewdoes not work for you. When I try that with your example it appears to work fine.That is:
Looks like:
Can you please show a code sample where you set the annotation view's width and height to be the same as the image view and say more about why this make the problem worse for you?
fabian-guerra commentedon Apr 3, 2017
Hi @evgzor sorry that #8603 (comment) didn't work for you. Complementing what I said you can use a parent view that fits the
UIViewsubview combined withMGLAnnotationView.centerOffsete.g.annotationView.centerOffset = CGVectorMake(0, -CGRectGetHeight(imageView.frame)/2.0);This will help you fix the offset you see in #8603 (comment).
evgzor commentedon Apr 4, 2017
@boundsj and @fabian-guerra for the moment I fixed like that: frame = CGRect(x: 0, y: 0, width: 4, height: 0). and overide centerOffset self.centerOffset = CGVector(dx: self.centerOffset.dx + self.bounds.width / 2 - .... Its workaround, but for complex annotation view which contains several views (not only image view) I have to use that approach. In general it implemented for SDK which can swith between MKMapView and MapBox map, by toggle and I have to always alighn high level api.
cansurmeli commentedon Apr 8, 2017
I'm trying to implement a custom MGLAnnotationView on iOS with Swift as well. And this issue seems to be continuing even on SDK 3.5.2.
Besides the annotation locations not updating continuously along with the map view, when the map view is initially launched, the annotations appear after a delay of couple of seconds but not immediately.
boundsj commentedon May 10, 2017
This should be fixed in the Mapbox iOS v3.5.4 release