forked from vospennikov/ClusterMap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5de4f6
commit d861f02
Showing
22 changed files
with
598 additions
and
401 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// ContentView.swift | ||
// Example-SwiftUI | ||
// | ||
// Created by Mikhail Vospennikov on 21.10.2023. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct ContentView: View { | ||
var body: some View { | ||
NavigationView(content: { | ||
Form(content: { | ||
Section { | ||
NavigationLink( | ||
destination: { LazyView(LegacyMap()) }, | ||
label: { Text("Map before iOS 17") } | ||
) | ||
} | ||
|
||
if #available(iOS 17.0, *) { | ||
Section { | ||
NavigationLink( | ||
destination: { LazyView(ModernMap()) }, | ||
label: { Text("Map since iOS 17") } | ||
) | ||
NavigationLink( | ||
destination: { LazyView(MapKitIntegration()) }, | ||
label: { Text("Map with MKLocalSearchCompleter") } | ||
) | ||
} | ||
} | ||
}) | ||
}) | ||
} | ||
} | ||
|
||
#Preview { | ||
ContentView() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// | ||
// LegacyMap.swift | ||
// Example-SwiftUI | ||
// | ||
// Created by Mikhail Vospennikov on 21.10.2023. | ||
// | ||
|
||
import ClusterMap | ||
import ClusterMapSwiftUI | ||
import MapKit | ||
import SwiftUI | ||
|
||
struct LegacyMap: View { | ||
@StateObject private var dataSource = DataSource() | ||
|
||
var body: some View { | ||
Map( | ||
coordinateRegion: dataSource.region, | ||
interactionModes: .all, | ||
annotationItems: dataSource.annotations, | ||
annotationContent: mapItem(for:) | ||
) | ||
.ignoresSafeArea() | ||
.readSize(onChange: { newValue in | ||
dataSource.mapSize = newValue | ||
}) | ||
.overlay(alignment: .bottom) { | ||
HStack { | ||
AsyncButton("Add annotations") { | ||
await dataSource.addAnnotations() | ||
} | ||
Spacer() | ||
AsyncButton("Remove annotations") { | ||
await dataSource.removeAnnotations() | ||
} | ||
} | ||
.padding() | ||
.buttonStyle(RoundedButton(fillColor: .accentColor, padding: 8)) | ||
} | ||
.onAppear { | ||
dataSource.bind() | ||
} | ||
} | ||
|
||
private func mapItem(for annotation: Annotation) -> some MapAnnotationProtocol { | ||
switch annotation.style { | ||
case .single: | ||
AnyMapAnnotationProtocol( | ||
MapPin(coordinate: annotation.coordinate) | ||
) | ||
case .cluster(let count): | ||
AnyMapAnnotationProtocol(MapAnnotation(coordinate: annotation.coordinate) { | ||
VStack(spacing: 0) { | ||
Image(systemName: "mappin.circle.fill") | ||
.font(.title) | ||
.foregroundColor(.red) | ||
|
||
Image(systemName: "arrowtriangle.down.fill") | ||
.font(.caption) | ||
.foregroundColor(.red) | ||
.offset(x: 0, y: -5) | ||
|
||
Text("\(count)") | ||
.font(.footnote) | ||
.foregroundColor(.black) | ||
.padding(4) | ||
.background { | ||
RoundedRectangle(cornerRadius: 4.0, style: .continuous) | ||
.foregroundColor(.white) | ||
} | ||
} | ||
}) | ||
} | ||
} | ||
} | ||
|
||
struct LegacyMap_Previews: PreviewProvider { | ||
static var previews: some View { | ||
LegacyMap() | ||
} | ||
} |
45 changes: 0 additions & 45 deletions
45
Example/Example-SwiftUI/App/Map/Annotations/ClusterAnnotationView.swift
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.