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

MGLUserAnnotation not displaying #1912

Closed
JohnRbk opened this issue Jul 22, 2015 · 4 comments
Closed

MGLUserAnnotation not displaying #1912

JohnRbk opened this issue Jul 22, 2015 · 4 comments
Assignees
Labels
bug iOS Mapbox Maps SDK for iOS
Milestone

Comments

@JohnRbk
Copy link

JohnRbk commented Jul 22, 2015

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"];
     }
}
@JohnRbk
Copy link
Author

JohnRbk commented Jul 22, 2015

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

@1ec5
Copy link
Contributor

1ec5 commented Jul 22, 2015

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

@incanus
Copy link
Contributor

incanus commented Jul 22, 2015

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.

@1ec5
Copy link
Contributor

1ec5 commented Jul 22, 2015

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

@incanus incanus added bug iOS Mapbox Maps SDK for iOS prerelease-os labels Jul 22, 2015
@1ec5 1ec5 self-assigned this Jul 23, 2015
@1ec5 1ec5 added this to the v0.6.0 milestone Jul 23, 2015
1ec5 added a commit that referenced this issue Jul 23, 2015
brunoabinader added a commit that referenced this issue Jul 24, 2015
1ec5 added a commit that referenced this issue Jul 24, 2015
Avoid passing invalid locations along to the map view delegate or user location annotation.

Also, If the user wants to visit the Prime Meridian or Equator, that’s their prerogative. Mapbox GL should show them where they’re at. Null Island is a different story.

Fixes #1912.
@1ec5 1ec5 removed the in progress label Jul 24, 2015
brunoabinader added a commit that referenced this issue Jul 27, 2015
Following the same steps from #1548 and #1912 for GLFW and iOS ports.
Also removed a redundant check if transform state is changing since
we're already dealing with that.
brunoabinader added a commit that referenced this issue Jul 31, 2015
brunoabinader added a commit that referenced this issue Aug 4, 2015
AndwareSsj pushed a commit to AndwareSsj/mapbox-gl-native that referenced this issue Nov 6, 2015
Avoid passing invalid locations along to the map view delegate or user location annotation.

Also, If the user wants to visit the Prime Meridian or Equator, that’s their prerogative. Mapbox GL should show them where they’re at. Null Island is a different story.

Fixes mapbox#1912.
AndwareSsj pushed a commit to AndwareSsj/mapbox-gl-native that referenced this issue Nov 6, 2015
Following the same steps from mapbox#1548 and mapbox#1912 for GLFW and iOS ports.
Also removed a redundant check if transform state is changing since
we're already dealing with that.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

No branches or pull requests

3 participants