@@ -1237,66 +1237,32 @@ open class NavigationMapView: UIView {
1237
1237
shapeLayer. textJustify = . constant( TextJustify . left)
1238
1238
shapeLayer. symbolZOrder = . constant( SymbolZOrder . auto)
1239
1239
shapeLayer. textFont = . constant( self . routeDurationAnnotationFontNames)
1240
+
1241
+ shapeLayer. symbolSortKey = . expression( Exp ( . get) {
1242
+ " sortOrder "
1243
+ } )
1240
1244
1241
- try style. addLayer ( shapeLayer)
1242
-
1243
- let symbolSortKeyString =
1244
- """
1245
- [ " get " , " sortOrder " ]
1246
- """
1247
-
1248
- if let expressionData = symbolSortKeyString. data ( using: . utf8) ,
1249
- let expJSONObject = try ? JSONSerialization . jsonObject ( with: expressionData, options: [ ] ) {
1250
- let property = " symbol-sort-key "
1251
- try style. setLayerProperty ( for: routeDurationAnnotationsLayerIdentifier,
1252
- property: property,
1253
- value: expJSONObject)
1245
+ let anchorExpression = Exp ( . match) {
1246
+ Exp ( . get) { " tailPosition " }
1247
+ 0
1248
+ " bottom-left "
1249
+ 1
1250
+ " bottom-right "
1251
+ " center "
1254
1252
}
1255
-
1256
- let expressionString =
1257
- """
1258
- [
1259
- " match " ,
1260
- [ " get " , " tailPosition " ],
1261
- [0],
1262
- " bottom-left " ,
1263
- [1],
1264
- " bottom-right " ,
1265
- " center "
1266
- ]
1267
- """
1268
-
1269
- if let expressionData = expressionString. data ( using: . utf8) ,
1270
- let expJSONObject = try ? JSONSerialization . jsonObject ( with: expressionData, options: [ ] ) {
1271
- try style. setLayerProperty ( for: routeDurationAnnotationsLayerIdentifier,
1272
- property: " icon-anchor " ,
1273
- value: expJSONObject)
1274
- try style. setLayerProperty ( for: routeDurationAnnotationsLayerIdentifier,
1275
- property: " text-anchor " ,
1276
- value: expJSONObject)
1253
+ shapeLayer. iconAnchor = . expression( anchorExpression)
1254
+ shapeLayer. textAnchor = . expression( anchorExpression)
1255
+
1256
+ let offsetExpression = Exp ( . match) {
1257
+ Exp ( . get) { " tailPosition " }
1258
+ 0
1259
+ Exp ( . literal) { [ 0.5 , - 1.0 ] }
1260
+ Exp ( . literal) { [ - 0.5 , - 1.0 ] }
1277
1261
}
1278
-
1279
- let offsetExpressionString =
1280
- """
1281
- [
1282
- " match " ,
1283
- [ " get " , " tailPosition " ],
1284
- [0],
1285
- [ " literal " , [0.5, -1]],
1286
- [ " literal " , [-0.5, -1]]
1287
- ]
1288
- """
1262
+ shapeLayer. iconOffset = . expression( offsetExpression)
1263
+ shapeLayer. textOffset = . expression( offsetExpression)
1289
1264
1290
- if let expressionData = offsetExpressionString. data ( using: . utf8) ,
1291
- let expJSONObject = try ? JSONSerialization . jsonObject ( with: expressionData, options: [ ] ) {
1292
- try style. setLayerProperty ( for: routeDurationAnnotationsLayerIdentifier,
1293
- property: " icon-offset " ,
1294
- value: expJSONObject)
1295
-
1296
- try style. setLayerProperty ( for: routeDurationAnnotationsLayerIdentifier,
1297
- property: " text-offset " ,
1298
- value: expJSONObject)
1299
- }
1265
+ try style. addLayer ( shapeLayer)
1300
1266
}
1301
1267
1302
1268
/**
0 commit comments