MGLSymbolStyleLayer has text can't show when offline

105 Views Asked by At

I successfully added an MGLSymbolStyleLayer layer to my map. the layer include image and text.

The layer can't show when offline.

MGLSymbolStyleLayer *lay = [[MGLSymbolStyleLayer alloc] initWithIdentifier:@"location_spot" source:source];
CGVector offset= CGVectorMake(0, 1);
lay.text = [NSExpression expressionForConstantValue:@"231.00m"];
lay.textOffset = [NSExpression expressionForConstantValue:@(offset)];
lay.textFontSize = [NSExpression expressionForConstantValue:@12.0];
lay.textColor = [NSExpression expressionForConstantValue:[UIColor blackColor]];
lay.textAllowsOverlap = [NSExpression expressionForConstantValue:@(YES)];
lay.iconImageName = [NSExpression expressionForConstantValue:obj.imageName];
lay.iconScale = [NSExpression expressionForConstantValue:@1.0];
lay.iconAllowsOverlap = [NSExpression expressionForConstantValue:@(YES)];

However, I try to comment the codes about text, the layer can show.

MGLSymbolStyleLayer *lay = [[MGLSymbolStyleLayer alloc] initWithIdentifier:@"location_spot" source:source];
CGVector offset= CGVectorMake(0, 1);
//lay.text = [NSExpression expressionForConstantValue:@"231.00m"];
//lay.textOffset = [NSExpression expressionForConstantValue:@(offset)];
//lay.textFontSize = [NSExpression expressionForConstantValue:@12.0];
//lay.textColor = [NSExpression expressionForConstantValue:[UIColor blackColor]];
//lay.textAllowsOverlap = [NSExpression expressionForConstantValue:@(YES)];
lay.iconImageName = [NSExpression expressionForConstantValue:obj.imageName];
lay.iconScale = [NSExpression expressionForConstantValue:@1.0];
lay.iconAllowsOverlap = [NSExpression expressionForConstantValue:@(YES)];

Maybe the question's reason is I never use the mapbox's offline font. so the font can't show. How to fix the bug?

0

There are 0 best solutions below