M.K. Polygon with holes

I searched through the Internet, but I could not find the answer to this question. Can I make a hole in the MK Polygon? Something like that:

enter image description here

I remember seeing something similar, but I'm not sure if this is related to iOS. This can be done and (if so) how should I start?

thanks

+4
source share
2 answers

To do this correctly, you should really look at parts of interiorPolygons MKPolygon .

+6
source

As @incanus points out, you can define an interiorPolygons array. For instance:

 NSUInteger interiorCount = 5; CLLocationCoordinate2D interiorCoordinates[interiorCount]; interiorCoordinates[0] = CLLocationCoordinate2DMake(...); interiorCoordinates[1] = CLLocationCoordinate2DMake(...); interiorCoordinates[2] = CLLocationCoordinate2DMake(...); interiorCoordinates[3] = CLLocationCoordinate2DMake(...); interiorCoordinates[4] = CLLocationCoordinate2DMake(...); MKPolygon* interiorPolygon = [MKPolygon polygonWithCoordinates:interiorCoordinates count:interiorCount]; interiorPolygon.title = @"interior polygon"; NSUInteger count = 5; CLLocationCoordinate2D coordinates[count]; coordinates[0] = CLLocationCoordinate2DMake(...); coordinates[1] = CLLocationCoordinate2DMake(...); coordinates[2] = CLLocationCoordinate2DMake(...); coordinates[3] = CLLocationCoordinate2DMake(...); coordinates[4] = CLLocationCoordinate2DMake(...); MKPolygon* polygon = [MKPolygon polygonWithCoordinates:coordinates count:count interiorPolygons:@[interiorPolygon]]; polygon.title = @"exterior polygon"; [self.mapView addOverlay:polygon]; 

This gives:

overlay with interior polygon

The loan goes to @incanus!

+1
source

Source: https://habr.com/ru/post/1481969/


All Articles