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

MGLUserAnnotation not displaying  #1912

Closed

Description

@JohnRbk

Looking at Stackoverflow post here it seems like MGLUserLocation::setLocation tests the distance between new and old locations before actually setting the new value. Because the initial latitude and longitude as set to MAXFLOAT, one of the conditionals checking distance always returns zero, preventing the new location value from being set:

 - (void)setLocation:(CLLocation *)newLocation {
    if ([newLocation distanceFromLocation:_location] /* always zero? */ 
     && newLocation.coordinate. latitude != 0 
     && newLocation.coordinate.longitude != 0)`...

I think this may be preventing the display of the MGLUserLocation annotation.

To test out my theory, I made the small change below (MGLUserLocation.m) and it seems to have worked - the MGLUserAnnotation now renders on my map as a pulsating circle.

 - (void)setLocation:(CLLocation *)newLocation
 {
    // new code to test my theory out
     if(_location.coordinate.latitude == MAXFLOAT || _location.coordinate.longitude == MAXFLOAT) {
          [self willChangeValueForKey:@"location"];
          _location = newLocation;
          [self didChangeValueForKey:@"location"];
    }`
    else if ([newLocation distanceFromLocation:_location] && newLocation.coordinate. latitude != 0 &&
             newLocation.coordinate.longitude != 0)
     {
         [self willChangeValueForKey:@"location"];
         _location = newLocation;
         [self didChangeValueForKey:@"location"];
     }
}

Activity

  1. JohnRbk commented on Jul 22, 2015

    @JohnRbk
    Author

    Forgot to mention: Xcode 7 Beta 3, 0.5.2 mapbox-gl build, targeting ios9.

  2. 1ec5 commented on Jul 22, 2015

    @1ec5
    Contributor

    Yes, this looks like an iOS 9-specific issue and the fix appears to work.

  3. incanus commented on Jul 22, 2015

    @incanus
    Contributor

    I have occasionally noticed an issue that I've been meaning to report with the user dot related to wrapped panning horizontally and the dot prematurely then disappearing. Try zooming out all the way, panning the world past a few times, and see what I mean. Not sure if related.

  4. 1ec5 commented on Jul 22, 2015

    @1ec5
    Contributor

    @incanus, I’m pretty sure that’s #1755.

  5. added
    iOS
    on Jul 22, 2015
  6. self-assigned this
    on Jul 23, 2015
  7. added this to the milestone on Jul 23, 2015
  8. added a commit that references this issue on Jul 23, 2015
    1919260
  9. added a commit that references this issue on Jul 24, 2015
    32c7805
  10. added 2 commits that reference this issue on Nov 6, 2015
    0612949
    3a9ef77
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugiOS

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions