Open riastrad opened 5 years ago
Agree! I think turning the earthquake code in this guide into an example could possibly work: https://www.mapbox.com/ios-sdk/api/maps/4.6.0/migrating-to-expressions.html
Totally agree! does someone have a working example?
Hey @luicm - nobody is working on this right now, but the link above has a piece of sample code that summarizes the use of MGL_MATCH:
let defaultColor = UIColor.blue
layer.circleColor = NSExpression(format: "MGL_MATCH(type, 'earthquake', %@, 'explosion', %@, 'quarry blast', %@, %@)",
UIColor.orange, UIColor.red, UIColor.yellow, defaultColor)
If you’d like to take that code and turn it into a fuller example, we would gladly accept further contributions to this project :)
hi @captainbarbosa, I am still trying to make it work, right now only get
'Unable to parse the format string "MGL_MATCH(grayLevel, '81': %@, '82': %@, '83': %@, '84': %@, '85': %@, '86': %@, '87': %@, '88': %@, '89': %@, '90': %@, '91': %@, '92': %@, '93': %@, '94': %@, '95': %@, '96': %@, '97': %@, '98': %@, '99': %@, '100': %@, '101': %@, '102': %@, '103': %@, '104': %@, '105': %@, '106': %@, '107': %@, '108': %@, '109': %@, '110': %@, '111': %@, '112': %@, '113': %@, '114': %@, '115': %@, '116': %@, '117': %@, '118': %@, '119': %@, '120': %@, '121': %@, '122': %@, '123': %@, '124': %@, '125': %@, '126': %@, '127': %@, '128': %@, '129': %@, '130': %@, '131': %@, '132': %@, '133': %@, '134': %@, '135': %@, '136': %@, '137': %@, '138': %@, '139': %@, '140': %@, '141': %@, '142': %@, '143': %@, '144': %@, '145': %@, '146': %@, '147': %@, '148': %@, '149': %@, '150': %@, '151': %@, '152': %@, '153': %@, '154': %@, '155': %@, '156': %@, '157': %@, '158': %@, '159': %@, '160': %@, '161': %@, '162': %@, '163': %@, '164': %@, '165': %@, '166': %@, '167': %@, '168': %@, '169': %@, '170': %@, '171': %@, '172': %@, '173': %@, '174': %@, '175': %@, '176': %@, '177': %@, '178': %@, '179': %@, '180': %@, '181': %@, '182': %@, '183': %@, '184': %@, '185': %@, '186': %@, '187': %@, '188': %@, '189': %@, '190': %@, '191': %@, '192': %@, '193': %@, '194': %@, '195': %@, '196': %@, '197': %@, '198': %@, '199': %@, '200': %@, '201': %@, '202': %@, '203': %@, '204': %@, '205': %@, '206': %@, '207': %@, '208': %@, '209': %@, '210': %@, '211': %@, '212': %@, '213': %@, '214': %@, '215': %@, '216': %@, '217': %@, '218': %@, '219': %@, '220': %@, '221': %@, '222': %@, '223': %@, %@) == 1"'
@luicm I'm not sure what your source data looks like so its difficult to tell what the issue is without further information. If you can send more details as well as a minimal test case over though our support contact form we can try to get someone from our team to help troubleshoot what might be happening.
I figure my issue, thank you very much. It was a casting issue. And it turned out that MGL_MATCH
was not the ideal function. this was my solution
layer.fillColor = NSExpression(format: "mgl_step:from:stops:(%@, %@, %@)",NSExpression(format: "CAST(grayLevel, 'NSNumber')"), defaultColor, stops)
Still it would be nice to have more clear examples :) I will try to make public my experience once I remove the code I can not disclose
MGL_MATCH
is a fairly commonly needed/used expression, but we don't currently have an example of it being implemented properly. I think it would be good to remedy this.