DEPRECATED-mapbox-ios-sdk icon indicating copy to clipboard operation
DEPRECATED-mapbox-ios-sdk copied to clipboard

Location dot moves with scrolling

Open russellquinn opened this issue 12 years ago • 56 comments

I think this bug just came about after the last big update, but if you track location, then start scrolling (thus canceling tracking) the dot jumps to the edge of the screen, following the scroll. Scroll left and right quickly to see it.

russellquinn avatar Jul 04 '12 20:07 russellquinn

@russellquinn, can you elaborate if you're still seeing this? I can't replicate.

incanus avatar Jul 23 '12 19:07 incanus

Yep, still an issue for me: https://dl.dropbox.com/u/44154592/LocationDotProblem.mov

russellquinn avatar Jul 23 '12 19:07 russellquinn

Ah, that helps. Thanks.

incanus avatar Jul 23 '12 19:07 incanus

Can we reopen this one? I don't have permission.

russellquinn avatar Jul 26 '12 21:07 russellquinn

Whoops.

incanus avatar Jul 26 '12 23:07 incanus

Man, I just cannot replicate this, even in your app (latest beta). Sure you're not doing something odd in your testing? I can never get the dot to jump.

incanus avatar Jul 27 '12 19:07 incanus

Happens in simulator, iPhone 4S and iPad (all on iOS 5.1.1) exactly like the movie I posted above. Very weird.

russellquinn avatar Jul 27 '12 19:07 russellquinn

I've tried timing and not timing it with the known update intervals (about 1s) between "pulses" of the location manager. Also tried different device orientations.

incanus avatar Jul 27 '12 19:07 incanus

There's absolutely no magic in the gestures required to replicate it, just tracking location then panning left and right like in the video shows it every time. It you can't see it in our app beta, it must be related to something else in our setups that differs. Hmm.

russellquinn avatar Jul 27 '12 19:07 russellquinn

Also, can you replicate this in any of our test apps or just yours?

incanus avatar Jul 31 '12 15:07 incanus

I just tried it in MapBox Me and no, it doesn't happen.

But, then I did some more investigation, and it seems related to annotations — if I don't add any annotations then it's fine.

I also tried adding annotations, but then returning nil in layerForAnnotation, and it still happens, so it's something about adding lots of annotations via addAnnotation. (We have a couple of hundred I guess.)

Note that it still happens even when browsing somewhere far away from any annotations (like, in a country without any) so I don't think it's directly related to the drawing of these annotations?

russellquinn avatar Jul 31 '12 18:07 russellquinn

Here's another video showing it:

https://dl.dropbox.com/u/44154592/LocationDotProblem_2.mov

russellquinn avatar Jul 31 '12 18:07 russellquinn

Cool, I will mock up a bunch of annotations on a loop and see what I can dig up.

incanus avatar Jul 31 '12 18:07 incanus

I'm working with 200 annotations and can't replicate. Are you creating layers on callback or by assigning layer upfront? Anything else odd about the way you are making annotations?

incanus avatar Jul 31 '12 22:07 incanus

Here's where I add the markers to the map. If I don't do this, it's fine.

The same problem happens whether I later return something in layerForAnnotation or I just return nil.

UIImage *markerImage = [UIImage imageNamed:@"mapMarker.png"];

 for (FieldReport *fieldReport in [fetchedResultsController fetchedObjects])
{
    CLLocationCoordinate2D location = CLLocationCoordinate2DMake([fieldReport.latitude doubleValue], [fieldReport.longitude doubleValue]);

    RMAnnotation *annonotion = [RMAnnotation annotationWithMapView:mapView coordinate:location andTitle:@""];
    annonotion.annotationType = kRMFieldReportAnnotationTypeName;
    annonotion.annotationIcon = markerImage;
    annonotion.anchorPoint = CGPointMake(0.4f, 1.0f);
    annonotion.userInfo = fieldReport;

    [mapView addAnnotation:annonotion];
}

russellquinn avatar Jul 31 '12 22:07 russellquinn

Weird. Only things that jump out at me are 1. you don't need to use annotationIcon as it doesn't do anything, and 2. try without the anchor point adjustment? But neither should really matter.

It must just have something to do with adding annotations, as you say.

incanus avatar Jul 31 '12 22:07 incanus

Well, I was storing the icon and anchor point in the annotation, then using that information in layerForAnnotation. But I tried removing it from the adding function, and still got the problem.

I wonder if you're playing around with it enough to recreate the bug? I get it if I tap locate-me, then do a pretty hard swipe to the left (so the map moves right) then drag back toward the location dot in really tiny steps.

russellquinn avatar Jul 31 '12 22:07 russellquinn

Where is the position of the dot calculated? I could try tracing/breaking on that to see if I can find anything?

russellquinn avatar Jul 31 '12 22:07 russellquinn

It's updated here: https://github.com/mapbox/mapbox-ios-sdk/blob/develop/MapView/Map/RMMapView.m#L2721

userLocation is an instance of RMUserLocation, which is an RMAnnotation that updates it's own coordinate based on a passed CLLocation.

incanus avatar Jul 31 '12 22:07 incanus

Also worth noting: when just dragging a small amount, the blue dot drags correctly with the map, but drag over a certain distance or tap-up and it snaps back to its previous location.

russellquinn avatar Jul 31 '12 22:07 russellquinn

This actually gives me an idea… I change the user location-related annotations' coordinate, but don't explicitly request an annotation redraw/correction loop.

incanus avatar Jul 31 '12 22:07 incanus

Here's another video detailing when the "snap back" happens. Watch the indicated tap-down state for when it's triggered by dragging too far, or lifting the finger up: https://dl.dropbox.com/u/44154592/MoreDot.mov

russellquinn avatar Jul 31 '12 22:07 russellquinn

And you aren't adjusting the coordinate of the userLocation annotation yourself? Be sure to filter on annotation.isUserLocationAnnotation = NO.

incanus avatar Jul 31 '12 22:07 incanus

Yep, I double-checked. I'm not manipulating any annotations.

russellquinn avatar Jul 31 '12 22:07 russellquinn

I put in a fix here related to the idea above… explicitly updating annotation positions after adjusting user position. Curious if this helps at all. I think the effect you see might be related to the annotation never getting its geo-position updated properly, thus snapping back into place at a bad geo point.

incanus avatar Jul 31 '12 23:07 incanus

Okay, I'll try. Though the effect does seem like it's snapping back to the same offset from the screen edge each time?

russellquinn avatar Aug 01 '12 00:08 russellquinn

Just tried it, but no, it didn't work :(

russellquinn avatar Aug 01 '12 00:08 russellquinn

Related to this -- are you simulating a trip in the simulator, i.e. a constantly-changing user location? It doesn't look like one of the template ones but I'm curious anyway. When the map is being dragged, location doesn't update, but when released, it will jump in place. Your video almost looks like that is happening.

incanus avatar Aug 01 '12 00:08 incanus

Nope, but I've tried simulating a trip (bug is still there). This happens both in the simulator and on devices though.

russellquinn avatar Aug 01 '12 00:08 russellquinn

I wonder if this has to do with the use of multiple simultaneous CLLocationManager objects, which I am not doing.

incanus avatar Aug 01 '12 00:08 incanus