I'm trying to write an expression to create custom symbology in a feature service. Currently I've made it this far:
var ftype = $feature.Feature_Type
var label = $feature.Label
var symbol = Replace(Replace(Replace(Replace(iif(ftype == "Hazard",iif(label == "Asbestos","Asbestos Hazard","Hazard"),ftype), ' ' , '' ), '(' , '' ), ')' , '' ), '-' , '' )
var d = Dictionary('Bore', 1, 'ExternalGate', 2, 'ExternalGateLocked', 3, 'GravelPit', 4, 'Hazard', 5, 'AsbestosHazard', 6, 'Helipad', 7, 'House', 8, 'InternalGate', 9, 'NoAccess', 10, 'OtherInfrastructure', 11, 'PhoneReception', 12, 'Shed', 13, 'WaterPoint', 14, 'WaterPointTank', 15)
var category = d.symbol
return category
The Replace functions are removing any spaces, brackets and dashes from the value returned from the $feature.Feature_Type value and work fine. The issue I'm having is I can't get the number value out of the dictionary using a variable as an input. I know this must be possible (or it would be pointless having dictionaries) but I can't figure out how to get the d.symbol (line 7) to use the value returned at line 4.
If I change line 7 to say:
var category = d.Bore
...then it all works. As soon as I change d.Bore back to d.symbol then it fails (even though the variable symbol is returning "Bore").
I also tried formatting d.symbol through text concatenation, but that didn't work either.