๋ค์ด๋ฒ์ง๋ iOS SDK๋ฅผ SwiftUI๋ก ๋ํํ ํจํค์ง.
์นด๋ฉ๋ผ ์ด๋ (์ด๋์
๋ผ์ด์ -> cameraPosition: Binding<CameraPosition>
)
Path ํ์ (์ด๋์
๋ผ์ด์ -> lineCoordinates: [CLLocationCoordinate2D]
)
Path ์คํ์ผํ (๋ชจ๋ํ์ด์ด -> pathStyle
)
Marker ํ์ (์ด๋์
๋ผ์ด์ -> markerItems
, markerContent
)
Map ํญ (๋ชจ๋ํ์ด์ด -> onMapTap(perform:)
)
ํ์ , ํธํธ ์ ๊ธ (๋ชจ๋ํ์ด์ด -> rotateGestureEnabled(:)
, tiltGestureEnabled(:)
)
struct ContentView: View {
@State var lineCoordinates = [CLLocationCoordinate2D](https://raw.github.com/sunghyun-k/NaverMapSwift/main/)
@State var locations = [
AnnotatedItem(name: "๋ณด๋ผ๋งค๊ณต์์ญ", coordinate: .init(latitude: 37.4954, longitude: 126.9182)),
AnnotatedItem(name: "๋ณด๋ผ๋งค์ญ", coordinate: .init(latitude: 37.4999, longitude: 126.9200))
]
@State var cameraPosition = NMFCameraPosition(
NMGLatLng(lat: 37.4922, lng: 126.9194),
zoom: 14.6
)
var body: some View {
NaverMap(
cameraPosition: $cameraPosition,
lineCoordinates: lineCoordinates,
markerItems: locations,
markerContent: { location in
NaverMapMarker(position: location.coordinate)
.image(.init(systemName: "tram.fill")!)
.captionText(location.name)
}
)
.tiltGestureEnabled(false)
.rotateGestureEnabled(false)
.onMapTap { coordinate in
lineCoordinates.append(coordinate)
locations.append(.init(name: "์ถ๊ฐํญ๋ชฉ", coordinate: coordinate))
}
.pathStyle {
NaverMapPath()
.color(.red)
}
}
}
struct AnnotatedItem: Identifiable {
let id = UUID()
var name: String
var coordinate: CLLocationCoordinate2D
}
link |
Stars: 4 |
Last commit: 1 year ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics