Skip to content
This repository has been archived by the owner on May 9, 2018. It is now read-only.

Location dot moves with scrolling #59

Open
russellquinn opened this issue Jul 4, 2012 · 56 comments
Open

Location dot moves with scrolling #59

russellquinn opened this issue Jul 4, 2012 · 56 comments
Labels

Comments

@russellquinn
Copy link

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.

@incanus
Copy link
Contributor

incanus commented Jul 23, 2012

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

@incanus incanus closed this as completed Jul 23, 2012
@russellquinn
Copy link
Author

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

@incanus
Copy link
Contributor

incanus commented Jul 23, 2012

Ah, that helps. Thanks.

@russellquinn
Copy link
Author

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

@incanus
Copy link
Contributor

incanus commented Jul 26, 2012

Whoops.

@incanus incanus reopened this Jul 26, 2012
@incanus
Copy link
Contributor

incanus commented Jul 27, 2012

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.

@russellquinn
Copy link
Author

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

@incanus
Copy link
Contributor

incanus commented Jul 27, 2012

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.

@russellquinn
Copy link
Author

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.

@incanus
Copy link
Contributor

incanus commented Jul 31, 2012

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

@russellquinn
Copy link
Author

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
Copy link
Author

Here's another video showing it:

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

@incanus
Copy link
Contributor

incanus commented Jul 31, 2012

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

@incanus
Copy link
Contributor

incanus commented Jul 31, 2012

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?

@russellquinn
Copy link
Author

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];
}

@incanus
Copy link
Contributor

incanus commented Jul 31, 2012

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.

@russellquinn
Copy link
Author

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
Copy link
Author

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

@incanus
Copy link
Contributor

incanus commented Jul 31, 2012

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.

@russellquinn
Copy link
Author

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.

@incanus
Copy link
Contributor

incanus commented Jul 31, 2012

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

@russellquinn
Copy link
Author

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

@incanus
Copy link
Contributor

incanus commented Jul 31, 2012

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

@russellquinn
Copy link
Author

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

@incanus
Copy link
Contributor

incanus commented Jul 31, 2012

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.

@russellquinn
Copy link
Author

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
Copy link
Author

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

@incanus
Copy link
Contributor

incanus commented Aug 1, 2012

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.

@russellquinn
Copy link
Author

I've played around with this for a while, but can't pin point it exactly. But, from breakpoints and commenting bits out, it seems as though when the location dot is moved off the screen, it constantly gets moved back to that relative point.

i.e.

  • You swipe the map, and the location dot goes to x:-100, y:100.
  • Then, for as long as the dot is off-screen, every time correctPositionOfAllAnnotationsIncludingInvisibles is called it resets the dot to x:-100, y:100. (it no longer updates these off-screen coordinates when the map is scrolled again).
  • When you drag the map, the dot moves with it, so it appears back on the screen again (as x becomes positive).
  • When the KVO detects a change, it snaps back to x:-100, y:100 again

In summary, the location dot's position isn't updated when it's off-screen — it retains whatever co-ordinates it had, when it first disappeared.

@incanus
Copy link
Contributor

incanus commented Aug 8, 2012

I still have never been able to reproduce this locally.

Can you try commenting out this line to see if it helps? I think you may be right about it being a display issue, as the userLocation.coordinate gets updated whenever Core Location updates, but maybe its layer isn't redrawing right.

@incanus
Copy link
Contributor

incanus commented Aug 9, 2012

[after some offline conversation]

Ok, give it a spin now and let me know what you think.

@russellquinn
Copy link
Author

Yes!!!! It seem like it's fixed!!!

On 8 Aug 2012, at 17:58, "Justin R. Miller" [email protected] wrote:

[after some offline conversation]

Ok, give it a spin now and let me know what you think.


Reply to this email directly or view it on GitHub.

@incanus
Copy link
Contributor

incanus commented Aug 9, 2012

Excellent. What I think was going on here was the following:

  1. Your app was taking a longer time to acquire a location at start, leaving userLocation.coordinate at 0, 0. Not sure why.
  2. When that happened before, current location would be shown as "Null Island", i.e. off the cost of West Africa.
  3. I then tapped "locate me" and it would take me someplace random, but then show the location dot in the center.
  4. The dot would want to stay there until such time as a real location was locked.

So, I made things behave better when a location isn't yet found, including not plotting user location and not allowing heading mode.

Going to close this out here.

@incanus incanus closed this as completed Aug 9, 2012
@russellquinn
Copy link
Author

There's some minor bad new, I did notice it still happening a few times last night. It's definitely 95% better, but I could still get in a state where the dot was redrawn at the same screen coordinates when scrolling. I haven't been able to reproduce it reliably yet, so let's leave this closed and I'll open a new one, when/if I can.

@incanus
Copy link
Contributor

incanus commented Aug 9, 2012

Yeah, I'll give some more attention to this today and clean it up a bit more. If you do see it happen, see if you can pause and check out the value of userLocation.coordinate.

@incanus
Copy link
Contributor

incanus commented Aug 14, 2012

Re-opening per @russellquinn reporting seeing it again.

@incanus incanus reopened this Aug 14, 2012
@incanus
Copy link
Contributor

incanus commented Aug 21, 2012

Let me know if you are still seeing this. I don't, including in your app.

@russellquinn
Copy link
Author

Yep, it still happens. I'll send you a new video.

@kiryl09
Copy link

kiryl09 commented Oct 23, 2012

the same issue, any updates?

@incanus
Copy link
Contributor

incanus commented Nov 14, 2012

Are people still seeing this in the latest develop? I've made a fair amount of annotation changes lately.

@incanus incanus closed this as completed Nov 17, 2012
@kiryl09
Copy link

kiryl09 commented Nov 17, 2012

I plan to verify this issue next week. Justin, should I use develop branch or you already merged with release?

@incanus
Copy link
Contributor

incanus commented Nov 17, 2012

I'm not going to merge to release until the release is good to go, probably a couple weeks out.

@kiryl09
Copy link

kiryl09 commented Nov 17, 2012

OK, i'll keep you informed

@kiryl09
Copy link

kiryl09 commented Nov 20, 2012

still exists http://vimeo.com/53958076

@incanus incanus reopened this Nov 20, 2012
@kiryl09
Copy link

kiryl09 commented Nov 20, 2012

steps to reproduce:
set zoom ~14.0
scroll top+right ~5km
after that scroll fast back bottom+left ~35km
and finally scroll fast but again top+right and you will see user location annotation

@incanus
Copy link
Contributor

incanus commented Dec 12, 2012

Is this still happening in the latest develop? Been working on annotation layers a bit and several aspects have changed.

@russellquinn
Copy link
Author

I haven't tested any updates to develop for a while, but I'll try to in the new year.

@derekmpeterson
Copy link

I'm seeing this issue when using the 1.0.2 binary framework.

@incanus
Copy link
Contributor

incanus commented Apr 23, 2013

@derekmpeterson, could you possibly include a video or otherwise give some info on the situation(s) in which you are seeing this?

@burrows111
Copy link

@incanus @derekmpeterson - I had this issue but fixed it a at the back end of next week, I am unsure if the fixes I applied will cause fault elsewhere but im still testing and appear OK:

  • (void)correctPositionOfAllAnnotationsIncludingInvisibles:(BOOL)correctAllAnnotations animated:(BOOL)animated
    {
    ........

    for (RMAnnotation *annotation in previousVisibleAnnotations)
    {
     //   if ( ! annotation.isUserLocationAnnotation) // remove this if statement
      //  {
            if (_delegateHasWillHideLayerForAnnotation)
                [_delegate mapView:self willHideLayerForAnnotation:annotation];
    
            annotation.layer = nil;
    
            if (_delegateHasDidHideLayerForAnnotation)
                [_delegate mapView:self didHideLayerForAnnotation:annotation];
    
            [_visibleAnnotations removeObject:annotation];
      //  } 
    }
    

}

The layer is correctly reapplied by the delegate but any rotation on the layer from the heading will need reapplying (didn't matter for me)

@lluisgh
Copy link

lluisgh commented Jul 11, 2013

I had exactly the same issue and @burrows111 solution works for me too. @incanus, could you check this? Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants