mapbox / mapbox-annotation-extension

Framework extensions that can be used with the Mapbox Maps SDK for iOS.
ISC License
11 stars 18 forks source link

MGLSymbolStyleAnnotation not showing up #57

Open NasH5169 opened 4 years ago

NasH5169 commented 4 years ago

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 commented 4 years ago

@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 () @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?