@@ -10,9 +10,11 @@ struct ColorThemeExample: View {
1010
1111 @State private var theme : Theme = . red
1212 @State private var panelHeight : CGFloat = 0
13+ @State private var atmosphereUseTheme = true
14+ @State private var circleUseTheme = true
1315
1416 var body : some View {
15- Map ( initialViewport: . camera( center: . init( latitude: 40.72 , longitude: - 73.99 ) , zoom: 11 , pitch: 45 ) ) {
17+ Map ( initialViewport: . camera( center: . init( latitude: 40.72 , longitude: - 73.99 ) , zoom: 2 , pitch: 45 ) ) {
1618 switch theme {
1719 case . default:
1820 EmptyMapContent ( )
@@ -22,8 +24,12 @@ struct ColorThemeExample: View {
2224 ColorTheme ( uiimage: monochromeTheme)
2325 }
2426
25- /// Defines a custom layer and source to draw the border line.
26- NYNJBorder ( )
27+ Atmosphere ( )
28+ . color ( . green)
29+ . colorUseTheme ( atmosphereUseTheme ? . default : . none)
30+
31+ TestLayer ( id: " blue-layer " , radius: 2 , color: . blue, coordinate: . init( latitude: 40 , longitude: - 104 ) , useTheme: circleUseTheme)
32+
2733 }
2834 . mapStyle ( . streets) /// In standard style it's possible to provide custom theme using `.standard(themeData: "base64String")`
2935 . additionalSafeAreaInsets ( . bottom, panelHeight)
@@ -36,6 +42,9 @@ struct ColorThemeExample: View {
3642 ColorButton ( color: . red, isOn: Binding ( get: { theme == . red } , set: { _, _ in theme = . red } ) )
3743 ColorButton ( color: . secondaryLabel, isOn: Binding ( get: { theme == . monochrome } , set: { _, _ in theme = . monochrome } ) )
3844 }
45+
46+ Toggle ( " Atmosphere Use Theme " , isOn: $atmosphereUseTheme)
47+ Toggle ( " Circle Use Theme " , isOn: $circleUseTheme)
3948 }
4049 . floating ( )
4150 }
@@ -82,33 +91,33 @@ private struct ColorButton: View {
8291 }
8392}
8493
85- private struct NYNJBorder : MapContent {
86- var body : some MapContent {
87- GeoJSONSource ( id: " border " )
88- . data ( . geometry( . lineString( LineString ( [
89- CLLocationCoordinate2D ( latitude: 40.913503418907936 , longitude: - 73.91912400100642 ) ,
90- CLLocationCoordinate2D ( latitude: 40.82943110786286 , longitude: - 73.9615887363045 ) ,
91- CLLocationCoordinate2D ( latitude: 40.75461056309348 , longitude: - 74.01409059085539 ) ,
92- CLLocationCoordinate2D ( latitude: 40.69522028220487 , longitude: - 74.02798814058939 ) ,
93- CLLocationCoordinate2D ( latitude: 40.65188756398558 , longitude: - 74.05655532615407 ) ,
94- CLLocationCoordinate2D ( latitude: 40.64339339389301 , longitude: - 74.13916853846217 ) ,
95- ] ) ) ) )
94+ private struct TestLayer : MapStyleContent {
95+ var id : String
96+ var radius : LocationDistance
97+ var color : UIColor
98+ var coordinate : CLLocationCoordinate2D
99+ var useTheme : Bool
96100
97- LineLayer ( id: " border " , source: " border " )
98- . lineColor ( . orange)
99- . lineWidth ( 8 )
100- . slot ( . bottom)
101+ var body : some MapStyleContent {
102+ let sourceId = " \( id) -source "
103+ FillLayer ( id: id, source: sourceId)
104+ . fillColorUseTheme ( useTheme ? . default : . none)
105+ . fillColor ( color)
106+ . fillOpacity ( 0.4 )
107+ LineLayer ( id: " \( id) -border " , source: sourceId)
108+ . lineColor ( color. darker)
109+ . lineColorUseTheme ( useTheme ? . default : . none)
110+ . lineOpacity ( 0.4 )
111+ . lineWidth ( 2 )
112+ GeoJSONSource ( id: sourceId)
113+ . data ( . geometry( . polygon( Polygon ( center: coordinate, radius: radius * 1000000 , vertices: 60 ) ) ) )
101114 }
102115}
103116
104117private let styleURL = Bundle . main. url ( forResource: " fragment-realestate-NY " , withExtension: " json " ) !
105118private let monochromeTheme = UIImage ( named: " monochrome_lut " ) !
106119private let redTheme = " iVBORw0KGgoAAAANSUhEUgAABAAAAAAgCAYAAACM/gqmAAAAAXNSR0IArs4c6QAABSFJREFUeF7t3cFO40AQAFHnBv//wSAEEgmJPeUDsid5h9VqtcMiZsfdPdXVzmVZlo+3ZVm+fr3//L7257Lm778x+prL1ff0/b//H+z/4/M4OkuP/n70Nc7f+nnb+yzb//sY6vxt5xXPn+dP/aH+GsXJekb25izxR/ypZ6ucUefv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AYAAwABgADAAGAAOAAcAAYAAwABgADIBO0xgADAAdCB0IHYgeMxkADAAdkGM7IPbf/pfuWlmj/lH/qH/UPzMZGAwABgADgAHAAGAAMAAYAAwABgADgAHAAGAAMAAYAJ3mMAAYAAg4Ao6A95jJAGAA6EDrQJfuclkj/8q/8q/8O1MHWv47Nv8xABgADAAGAAOAAcAAYAAwABgADAAGAAOAAcAAYAB0msYAYADoQOhA6ED0mMkAYADogBzbAbH/9r/YFWWN+kf9o/5R/8xkYDAAGAAMAAYAA4ABwABgADAAGAAMAAYAA4ABwABgAHSawwBgACDgCDgC3mMmA4ABoAOtA126y2WN/Cv/yr/y70wdaPnv2PzHAGAAMAAYAAwABgADgAHAAGAAMAAYAAwABgADgAHQaRoDgAGgA6EDoQPRYyYDgAGgA3JsB8T+2/9iV5Q16h/1j/pH/TOTgcEAYAAwABgADAAGAAOAAcAAYAAwABgADAAGAAPgyQ2AT4NBIB3ew5dkAAAAAElFTkSuQmCC "
107120
108- private extension StandardTheme {
109- static let red = StandardTheme ( rawValue: " red " )
110- }
111-
112121struct ColorThemeExample_Previews : PreviewProvider {
113122 static var previews : some View {
114123 StandardStyleImportExample ( )
0 commit comments