Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MGLSymbolStyleAnnotation not showing up #57

Open
NasH5169 opened this issue Nov 6, 2019 · 1 comment
Open

MGLSymbolStyleAnnotation not showing up #57

NasH5169 opened this issue Nov 6, 2019 · 1 comment

Comments

@NasH5169
Copy link

NasH5169 commented Nov 6, 2019

Hi!

First of all, thanks for this great lib.

I am trying to display a MGLSymbolStyleAnnotation without success. I tried with the other StyleAnnotation like the Circle one and it's working perfectly.

Bellow my piece of test code:

MGLSymbolAnnotationController *symbolController = [[MGLSymbolAnnotationController alloc] initWithMapView:mapView];
    
    MGLSymbolStyleAnnotation *symbolAnnotation = [[MGLSymbolStyleAnnotation alloc] initWithCoordinate:CLLocationCoordinate2DMake(46, 0)];
    symbolAnnotation.text = @"TEST";
    symbolAnnotation.textFontSize = 16;
    symbolAnnotation.textHaloColor = UIColor.brownColor;
    symbolAnnotation.textColor = UIColor.blueColor;
    [symbolController addStyleAnnotation:symbolAnnotation];

There is no image attached to this Symbol but it's on purpose. I of course tried by attaching an image but same result, the annotation is not showing up. This piece of code is well located in the didFinishLoadingStyle callback.

Thank you in advance.

@captainbarbosa
Copy link
Contributor

@NasH5169 Hey there, I tried reproducing your issue and I wasn't able to...your exact code that you posted here seems to work for me:

Screenshot 2019-11-08 16 37 46

Here's the code:
#import "SymbolExampleViewController.h"
@import Mapbox;
@import MapboxAnnotationExtension;

@interface SymbolExampleViewController () <MGLMapViewDelegate>

@property (nonatomic) MGLMapView *mapView;

@end

@implementation SymbolExampleViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.mapView = [[MGLMapView alloc] initWithFrame:self.view.bounds
        styleURL:[MGLStyle lightStyleURL]];
    
    // Set the map’s center coordinate and zoom level.
    self.mapView.centerCoordinate = CLLocationCoordinate2DMake(46, 0);
    self.mapView.zoomLevel = 10.5;
    
    self.mapView.delegate = self;
    [self.view addSubview: self.mapView];
}

- (void)mapView:(MGLMapView *)mapView didFinishLoadingStyle:(MGLStyle *)style {
    
    MGLSymbolAnnotationController *symbolController = [[MGLSymbolAnnotationController alloc] initWithMapView:mapView];

    MGLSymbolStyleAnnotation *symbolAnnotation = [[MGLSymbolStyleAnnotation alloc] initWithCoordinate:mapView.centerCoordinate];
    symbolAnnotation.text = @"TEST";
    symbolAnnotation.textFontSize = 16;
    symbolAnnotation.textHaloColor = UIColor.brownColor;
    symbolAnnotation.textColor = UIColor.blueColor;
    [symbolController addStyleAnnotation:symbolAnnotation];
}

@end

Can you confirm your code looks the same?

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

No branches or pull requests

2 participants