MapKit adding annotation only in water

Viewed 16

I'm trying to adding MKAnnotation only in water (Lake, sea ,ocean etc..) I use a CLPlacemark to check if annotation is in water but i'm always in case "Not in water" :

@objc func functionName (notification: NSNotification) {

    let placeMark = MyPlaceMark(location: CLLocation(latitude: location.latitude, longitude: location.longitude), name: "", postalAddress: nil)
    print(placeMark)

    if placeMark.inlandWater != nil || placeMark.ocean != nil {
    pinDetail = notification.object as? PinDetail
    savePinToFirestore(name: pinDetail.name, location: location, subtitle: pinDetail.pinDetailText, image: pinDetail.imageName)
    reloadTable()
    } else {
        print("Not in water")
    }
}

my coords in location are in sea but placeMark.inlandWater & placeMark.ocean still equal to nil Any ideas ? Thanks

0 Answers
Related