MGLStyle’s layers property should be ordered from back to front, not from front to back.
In #6097, I said:
The layers array is ordered from front to back, for consistency with Cocoa, as opposed to mbgl’s back-to-front ordering.
I was mistaken: similar arrays in Cocoa are ordered from back to front (NSView.subviews, UIView.subviews, UIApplication.windows) or specify no explicit order (NSApplication.windows). (Apple Events and AppleScript do treat “front” as a synonym for “first” and “back” as a synonym for “last”, but that shouldn’t inform the API we expose in this SDK.)
I think a last-minute breaking change before the release is probably the right decision in the long run. Reversing the array will simplify MGLStyle somewhat, as it removes an impedance mismatch with mbgl. It’ll also make the iOS and macOS SDKs more consistent with the Android SDK and GL JS. Moreover, the layers property was only published a few days ago in beta 5, along with more convenient methods like -insertLayer:aboveLayer:, so direct indexing into layers should be relatively rare.
/cc @boundsj @frederoni @ericrwolfe @bsudekum
MGLStyle’s
layersproperty should be ordered from back to front, not from front to back.In #6097, I said:
I was mistaken: similar arrays in Cocoa are ordered from back to front (
NSView.subviews,UIView.subviews,UIApplication.windows) or specify no explicit order (NSApplication.windows). (Apple Events and AppleScript do treat “front” as a synonym for “first” and “back” as a synonym for “last”, but that shouldn’t inform the API we expose in this SDK.)I think a last-minute breaking change before the release is probably the right decision in the long run. Reversing the array will simplify MGLStyle somewhat, as it removes an impedance mismatch with mbgl. It’ll also make the iOS and macOS SDKs more consistent with the Android SDK and GL JS. Moreover, the
layersproperty was only published a few days ago in beta 5, along with more convenient methods like-insertLayer:aboveLayer:, so direct indexing intolayersshould be relatively rare./cc @boundsj @frederoni @ericrwolfe @bsudekum