This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Cannot apply multiple to zoom level styling #11277
Copy link
Copy link
Closed
Labels
CoreThe cross-platform C++ core, aka mbgl
Description
Platform: iOS
Mapbox SDK version: v4.0.0-beta.2
Steps to trigger behavior
Consider the following code:
let routeLineWidthAtZoomLevels: [Int: NSExpression] = [
10: NSExpression(forConstantValue: 8),
13: NSExpression(forConstantValue: 9),
16: NSExpression(forConstantValue: 11),
19: NSExpression(forConstantValue: 22),
22: NSExpression(forConstantValue: 28)
]
lineCasing.lineWidth = NSExpression(format: "FUNCTION($zoomLevel, 'mgl_interpolateWithCurveType:parameters:stops:', 'linear', nil, %@) * 0.85", routeLineWidthAtZoomLevels)Expected behavior
Each zoom level is scaled by a factor of 0.85
Actual behavior
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid property value: "zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000105f9812b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00000001065fff41 objc_exception_throw + 48
2 CoreFoundation 0x000000010600d245 +[NSException raise:format:] + 197
3 Mapbox 0x000000010256f6bb _Z23MGLZoomLevelForAltitudeddd6CGSize + 43393
4 Mapbox 0x000000010259e077 _Z27MGLTimeIntervalFromDurationNSt3__16chrono8durationIxNS_5ratioILl1ELl1000000000EEEEE + 84156
5 MapboxNavigation 0x0000000102d03b8b _T016MapboxNavigation0B7MapViewC24alternateRouteStyleLayerSo08MGLStyleH0CSS10identifier_So9MGLSourceC6sourcetF + 427
6 MapboxNavigation 0x0000000102cf3231 _T016MapboxNavigation0B7MapViewC10showRoutesySay0A10Directions5RouteCG_Si8legIndextF + 27873
7 Voyage 0x0000000101f12a88 _T06Voyage31DirectionsPreviewViewControllerC26calculateRouteAndUpdateMap33_A08FD54413D51CEC9931375EB0B787F0LLySC29MBDirectionsProfileIdentifierV10identifier_tFySay06MapboxB08WaypointCGSg_SayAI0G0CGSgSo7NSErrorCSgtcfU_ + 6008
8 Voyage 0x0000000101f1874e _T06Voyage31DirectionsPreviewViewControllerC26calculateRouteAndUpdateMap33_A08FD54413D51CEC9931375EB0B787F0LLySC29MBDirectionsProfileIdentifierV10identifier_tFySay06MapboxB08WaypointCGSg_SayAI0G0CGSgSo7NSErrorCSgtcfU_TA + 126
9 MapboxDirections 0x0000000102a83019 _T016MapboxDirections0B0C9calculateSo18URLSessionDataTaskCAA12RouteOptionsC_ySayAA8WaypointCGSg_SayAA0G0CGSgSo7NSErrorCSgtc17completionHandlertFys10DictionaryVySSypGcfU_ + 1545
10 MapboxDirections 0x0000000102a8318c _T016MapboxDirections0B0C9calculateSo18URLSessionDataTaskCAA12RouteOptionsC_ySayAA8WaypointCGSg_SayAA0G0CGSgSo7NSErrorCSgtc17completionHandlertFys10DictionaryVySSypGcfU_TA + 124
11 MapboxDirections 0x0000000102a88f0e _T016MapboxDirections0B0C8dataTask33_9AB848AFC329A49F8F01862214F64FC2LLSo014URLSessionDataD0C10Foundation3URLV4with_ys10DictionaryVySSypGc17completionHandlerySo7NSErrorCc05errorS0tFyAH0M0VSg_So11URLResponseCSgs5Error_pSgtcfU_yycfU0_ + 126
12 MapboxDirections 0x0000000102a8cb4f _T016MapboxDirections0B0C8dataTask33_9AB848AFC329A49F8F01862214F64FC2LLSo014URLSessionDataD0C10Foundation3URLV4with_ys10DictionaryVySSypGc17completionHandlerySo7NSErrorCc05errorS0tFyAH0M0VSg_So11URLResponseCSgs5Error_pSgtcfU_yycfU0_TA + 79
13 MapboxDirections 0x0000000102a88e79 _T0Ix_IyB_TR + 41
14 libdispatch.dylib 0x00000001086d62f7 _dispatch_call_block_and_release + 12
15 libdispatch.dylib 0x00000001086d733d _dispatch_client_callout + 8
16 libdispatch.dylib 0x00000001086e25f9 _dispatch_main_queue_callback_4CF + 628
17 CoreFoundation 0x0000000105f5ae39 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
18 CoreFoundation 0x0000000105f1f462 __CFRunLoopRun + 2402
19 CoreFoundation 0x0000000105f1e889 CFRunLoopRunSpecific + 409
20 GraphicsServices 0x000000010ad459c6 GSEventRunModal + 62
21 UIKit 0x00000001036d35d6 UIApplicationMain + 159
22 Voyage 0x0000000101f49f87 main + 55
23 libdyld.dylib 0x0000000108753d81 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
/cc @1ec5 @anandthakker
Metadata
Metadata
Assignees
Labels
CoreThe cross-platform C++ core, aka mbgl
Activity
anandthakker commentedon Feb 22, 2018
@bsudekum The error message here could definitely be more helpful, but it's expected: if an expression references
$zoom, then the outermost expression must be theFUNCTION($zoomLevel,...)part (the Style JSON version of this constraint is described under "Camera expressions" here). To get the effect you want, you'd have to scale the values inrouteLineWidthAtZoomLevelsby0.85instead.1ec5 commentedon Feb 22, 2018
This is related to the discussion in mapbox/mapbox-navigation-ios#1076 (comment). I think it’s going to surprise some developers that they can’t make a camera expression part of a larger expression.
jfirebaugh commentedon Jul 2, 2018
This restriction is a requirement for efficient interpolation of properties while zooming. I don't see us relaxing it in the short or medium term -- or even in the long term.