Reputation: 314
https://developers.google.com/maps/documentation/ios/?goback=%2Egde_73521_member_195822698 Polylines can be drawn, but no polygons with IOS API?
Am I missing something?
Upvotes: 1
Views: 2080
Reputation: 1573
I know this is a really old thread but it took a while for me to find this so I thought I'd share what I am now using since the question remains open.
First assign a GMSMutablePath
for all polygon points using lat/long - the below example outlines the Coast of Suffolk, UK:
GMSMutablePath *poly = [GMSMutablePath path];
[poly addCoordinate:CLLocationCoordinate2DMake(52.506191, 1.83197)];
[poly addCoordinate:CLLocationCoordinate2DMake(52.05249, 1.650696)];
[poly addCoordinate:CLLocationCoordinate2DMake(51.92225, 1.321106)];
[poly addCoordinate:CLLocationCoordinate2DMake(51.996719, 1.219482)];
[poly addCoordinate:CLLocationCoordinate2DMake(52.049112, 1.244202)];
[poly addCoordinate:CLLocationCoordinate2DMake(52.197507, 1.334839)];
[poly addCoordinate:CLLocationCoordinate2DMake(52.519564, 1.801758)];
Then create the GMSPolygon
using the path, set it's appearance properties and assign it to the map!
GMSPolygon *polygon = [GMSPolygon polygonWithPath:poly];
polygon.fillColor = [UIColor colorWithRed:0 green:0.25 blue:0 alpha:0.3];
polygon.strokeColor = [UIColor greenColor];
polygon.strokeWidth = 5;
polygon.map = self.googleMap;
Hope it helps someone out there..
Upvotes: 2