I have a requirement where there are nearly hundreds of polygon data coming from API and I have to draw them quickly in the map.
Right now it is taking a significant time to draw 50 polygons on map at a time. So I am thinking a way to cluster those polygons & only draw/show when I pinch in to a region. I only read about MKClusterAnnotation but never heard about clustering polygon. Is there any other way I can optimize drawing polygon?
Its not possible to cluster
MKPolygons, but you can mergeMKPolygons using the MKPolygon-GPC library.Example below using this library creates a union of two
MKPolygonobjects:It is also possible to check if two polygons are intersecting, in example below it checks if 2 polygons are intersecting, then it merges:
Below is a
MKPolygonArray extension that you can use to merge as manyMKPolygons:Usage-1 uses polygons array
[MKPolygon]:Usage-2 uses coordinates array
[[CLLocationCoordinate2D]]: