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

fixes #1675: fix initial annotation markers #2289

Merged
merged 1 commit into from
Sep 9, 2015

Conversation

incanus
Copy link
Contributor

@incanus incanus commented Sep 9, 2015

This does two things:

  1. It abstracts the pattern of checking if there are any stale annotation tiles (moving them to the caller in the process), then passing those back to the update routine to invalidate said annotation tiles.
  2. It uses that routine additionally in response to the sprite store loading, which necessarily loads after the sprite, which is after the style, which is the only way that either runtime-provided marker imagery or the default style sprite marker imagery will work. It extends the Observer pattern already used in the style and the map context for decoupled communications.

@incanus incanus added this to the ios-v2.1.0 milestone Sep 9, 2015
@incanus
Copy link
Contributor Author

incanus commented Sep 9, 2015

Here's a simple diff to check the behavior:

diff --git a/ios/app/MBXViewController.mm b/ios/app/MBXViewController.mm
index d94e41b..e7548c6 100644
--- a/ios/app/MBXViewController.mm
+++ b/ios/app/MBXViewController.mm
@@ -82,7 +82,14 @@ static NSUInteger const kStyleVersion = 8;
                                                                              target:self
                                                                              action:@selector(locateUser)];

-    [self restoreState:nil];
+//    [self restoreState:nil];
+
+    self.mapView.debugActive = YES;
+
+    MGLPointAnnotation *point = [MGLPointAnnotation new];
+    point.coordinate = CLLocationCoordinate2DMake(45, -123);
+    [self.mapView addAnnotation:point];
+    [self.mapView setCenterCoordinate:point.coordinate zoomLevel:15 animated:NO];
 }

 - (void)saveState:(__unused NSNotification *)notification
@@ -354,6 +361,8 @@ static NSUInteger const kStyleVersion = 8;

 - (MGLAnnotationImage *)mapView:(MGLMapView * __nonnull)mapView imageForAnnotation:(id <MGLAnnotation> __nonnull)annotation
 {
+    if (annotation.title == nil) return [MGLAnnotationImage annotationImageWithImage:[UIImage imageNamed:@"Icon.png"] reuseIdentifier:@"foo"];
+
     NSString *title = [(MGLPointAnnotation *)annotation title];
     NSString *lastTwoCharacters = [title substringFromIndex:title.length - 2];

@incanus
Copy link
Contributor Author

incanus commented Sep 9, 2015

I should add that this updateAnnotationTiles() wholesale business is ripe for replacement as part of #1688, which should move to incremental parsing and rendering for annotations.

@incanus
Copy link
Contributor Author

incanus commented Sep 9, 2015

Mind giving this a pass @friedbunny @1ec5 in light of the First Steps guide? Working good for me.

@friedbunny
Copy link
Contributor

Lookin' at this...

@friedbunny
Copy link
Contributor

Works well, polylines and markers both show up immediately when drawn in viewDidLoad:. 👍

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

Successfully merging this pull request may close these issues.

2 participants