When closing the lines of a polygon that is being drawn on the map using MapKit, we observe that the polygon is no longer closing. We didn't have any changes in the application and it stopped working after the iOS version 15.3 update. Until the previous versions it worked normally.
if (mainGleba.tamanhoArea != nil && mainGleba.tamanhoArea! > 0) {
if let areaText = formatter.string(from: mainGleba.tamanhoArea!) {
print("Área text: \(areaText)")
areaSize = sizeArea as! Double
textFieldArea.text
= "\(areaText.replacingOccurrences(of: ",", with:
".").formatToLocalCurrency(with: 2)) \.
(mainGleba.unidadeMedidaArea!)"
}
}else{
if let areaText = formatter.string(from: sizeArea) {
print("Área text: \(areaText)")
areaSize = sizeArea as! Double
textFieldArea.text
= "\(areaText.replacingOccurrences(of: ",", with:
".").formatToLocalCurrency(with: 2)) \
(mainGleba.unidadeMedidaArea!)"
}
}
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
let polygonView = MKPolygonRenderer(overlay: overlay)
polygonView.strokeColor = Color.white()
if let _ = overlay as? MKPolygon{
polygonView.fillColor = Color.set(Color.white(), alpha: 0.2)
}
if(isAreaEnquadrada){
polygonView.strokeColor = Color.blue().withAlphaComponent(0.5)
polygonView.fillColor = Color.blue().withAlphaComponent(0.3)
}
polygonView.lineWidth = 2.0
polygonView.lineCap = CGLineCap.butt
isAreaEnquadrada = false
return polygonView
}