I have a point dataset that is intended only as labels. Each label has a pre-calculated minZoom attribute to one decimal place, e.g. 6.1. While there are labels that share the same value, they vary considerably. I've figured out how to programmatically add a single label. It's workable, I suppose, to add a layer for each label. But performance may suffer. Is there a way, either via Mapbox Studio or programmatically (for the iOS SDK) to set the camera stops individually for each label but keep them within a single layer?
func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle)
{
// Try adding point with label
let coordinates: CLLocationCoordinate2D = CLLocationCoordinate2D(latitude: 49, longitude: -114)
let testPt = MGLPointFeature()
testPt.coordinate = coordinates
testPt.title = "Testing label"
testPt.attributes = ["title": testPt.title as Any]
let src = MGLShapeSource(identifier: "testPtID", features: [testPt], options: nil)
mapView.style?.addSource(src)
let symbols = MGLSymbolStyleLayer(identifier: "testPtSym", source: src)
let color = UIColor(red: 0.08, green: 0.75, blue: 0.96, alpha: 1.0)
symbols.textColor = MGLStyleValue(rawValue: color)
symbols.text = MGLStyleValue(rawValue: "{title}")
symbols.textFontSize = MGLStyleValue(rawValue: 24)
symbols.textOpacity = MGLStyleValue(interpolationMode: .exponential,
cameraStops: [
6: MGLStyleValue(rawValue: 0),
6.1: MGLStyleValue(rawValue: 1)
], options: nil
)
mapView.style?.addLayer(symbols)
}