Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // MapPolyline.swift
- // playgroundProj
- //
- // Created by Kraszni Marcell on 02/04/2024.
- //
- import SwiftUI
- import MapKit
- import BottomSheet
- struct MapPolyline: View {
- @State var polylinePositions: [CLLocationCoordinate2D] = []
- @State var currentCoord = CLLocationCoordinate2D(latitude: 0, longitude: 0)
- @State var bottomSheetPos: BottomSheetPosition = .dynamicBottom
- var body: some View {
- Map { // The error shows on this line
- MapPolyline(coordinates: polylinePositions) // The bug causer is this shitty line (can you tell I'm aggravated? btw the error is "No exact matches in call to initializer" if you forgot)
- Marker("", systemImage: "mappin", coordinate: currentCoord)
- }
- .onMapCameraChange(frequency: .continuous, { context in
- currentCoord = context.camera.centerCoordinate
- })
- .bottomSheet(bottomSheetPosition: $bottomSheetPos, switchablePositions: [.dynamicBottom, .dynamic]) {
- HStack {
- Text("Current pos: \(currentCoord.latitude) \(currentCoord.longitude)")
- .bold()
- }
- .padding(.all)
- } mainContent: {
- VStack {
- Button(action: {
- polylinePositions.append(currentCoord)
- }, label: {
- HStack {
- Image(systemName: "mappin.and.ellipse")
- Text("Plot onto map")
- }
- })
- .buttonStyle(.bordered)
- }
- .padding(.all, 40)
- }
- }
- }
- #Preview {
- MapPolyline(polylinePositions: [CLLocationCoordinate2D(latitude: 1, longitude: 1.6543), CLLocationCoordinate2D(latitude: 1.6254, longitude: 1.6543)])
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement