Help wanted for newbie

hi folks! I'm new to swift but started a project with my son. we want to run this little code for converting GK4 coordinates into latitude longitude, store them in a listing and show them by click in Apple Maps. we've import a gausskrueger repository to our project folder. that's working surprisedly:) we've got some output in simulator and apple map open but sadly its showing 0.00000 N, 0.00000 and for sure the coordinates are in the blue ocean. can someone have a look?

import SwiftUI

import MapKit

import GaussKrueger

struct CoordinateConverterView: View {

    @State private var xInput = ""

    @State private var yInput = ""

    @State private var coordinates: [String] = []

    

    var body: some View {

        VStack {

            HStack {

                TextField("X", text: $xInput)

                TextField("Y", text: $yInput)

            }

            Button("Convert") {

                if let x = Double(xInput), let y = Double(yInput) {

                    let coord = GKCoordinate(x: x, y: y).asWGS

                    let coordinateString = "Latitude: (String(describing: coord?.latitude)) Longitude: (String(describing: coord?.longitude))"

                    coordinates.append(coordinateString)

                    xInput = ""

                    yInput = ""

                }

            }

            List(coordinates, id: .self) { coordinate in

                HStack {

                    Text(coordinate)

                        .font(.system(size: 10))

                    Spacer()

                    Button(action: {

                        self.showInMaps(coordinate: coordinate)

                    }, label: {

                        Image(systemName: "mappin.and.ellipse")

                    })

                }

            }

        }

    }

    

    func showInMaps(coordinate: String) {

        let scanner = Scanner(string: coordinate)

        var latitude: Double = 0

        var longitude: Double = 0

        scanner.scanString("Latitude: ", into: nil)

        scanner.scanDouble(&latitude)

        scanner.scanString(", Longitude: ", into: nil)

        scanner.scanDouble(&longitude)

        

        let coordinate = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)

        let mapItem = MKMapItem(placemark: MKPlacemark(coordinate: coordinate, addressDictionary: nil))

        mapItem.openInMaps(launchOptions: nil)

    }

}

There's a lot going on in your sample code, so you need to narrow down where the issue is.
It looks like you may have multiple issues, so you may want to start with simpler code first?

Some points to consider:

Are you successfully creating a valid GKCoordinate?
If so, are you getting a valid WGS coordinate from it?

A SwiftUI array-based List requires that each element is uniquely identifiable.
Your coordinates may not be uniquely identifiable (since the user could enter the same values more than once.

Why store the coordinate values as string, and then re-scan them to numbers... why not just store them as coordinates?
(Could there be an error in either side of this conversion process?)

Are you passing a valid coordinate to showinMaps?

Are you passing a valid MKMapItem to Maps?

Help wanted for newbie
 
 
Q