Hello, I am using iOS MapKit via kotlin/compose UI...
# multiplatform
s
Hello, I am using iOS MapKit via kotlin/compose UIKitView. I am able to create an Annotation but cannot create a MKPolygon because I cannot add a List of Coordinates to the constructor. Am I missing something or is the MapKit Interop just not ready / currently lacking features?
m
I haven't fully played with this, but I think you'll Need to use a
memScope
to create a native array of the coordinates, and then call
MKPolygon.polygonWithCoordinates()
It's strange that they have a low level API for creating something like that.
s
Hey thanks for the help. I have never used memScope so far so I will begin by reading into that topic first. This should help me a ton 🙂
m
Documentation on CValues and CPointers I felt was very lacking. Hopefully it is better now.
s
Hey again, it seemed relative straight forward, but I cannot wrap my head around as to why I cannot set values into the cPointer array:
Copy code
fun createCPointer(coordinates: List<CLLocationCoordinate2D>): CPointer<CLLocationCoordinate2D> {
    return memScoped {
        val cPointer = allocArray<CLLocationCoordinate2D>(coordinates.size)

        coordinates.forEachIndexed { index, clLocationCoordinate2D ->
            cPointer[index] = clLocationCoordinate2D // <-- Not Possible. No setter.
        }
        cPointer
    }
}
Any clue as to how I am using the CPointer wrong?
Classic, after posting I found out that the Pointer is already filled with the LocationCoordinates and I can access the properties:
Copy code
cPointer[index].latitude = clLocationCoordinate2D.latitude
156 Views