Meiji Meiji - 3 months ago 16
iOS Question

How do I convert an array of MKMapPoint values to a MKPolygon overlay

I have a list of

MKMapPoint
values and I'd like to be able to convert these to a
MKPolygon
overlay. Is this possible?

List<MKMapPoint> pointsList = new List<MKMapPoint>();


I've tried the following, but it doesn't seem to work:

MKPolygon polygon = MKPolygon.FromPoints(pointsList);


I get the error:


Error: Argument 1: cannot convert from
System.Collections.Generic.List<MapKit.MKMapPoint>
to
MapKit.MKMapPoint[]


Answer

Convert the list to an array by using .ToArray():

MKPolygon polygon = MKPolygon.FromPoints(pointsList.ToArray());

Comments