0

I have markers on my GMSMapView and I want to add an overlay to the country in which the marker is located. The code I have is below.

[geocode geocodeAddressString:[NSString stringWithFormat:@"%@, %@",placeName,cityName] inRegion:region completionHandler:^(NSArray *placemarks, NSError *error) {
  if(placemarks && placemarks.count > 0)
  {
     CLPlacemark *topResult = [placemarks objectAtIndex:0];
     GMSMutablePath *rect = [GMSMutablePath path];
     // Add Northeast
     [rect addCoordinate:CLLocationCoordinate2DMake(region.center.latitude + region.span.latitudeDelta / 2,region.center.longitude - region.span.longitudeDelta / 2)];
     // Add Southwest
     [rect addCoordinate:CLLocationCoordinate2DMake(region.center.latitude - region.span.latitudeDelta / 2,region.center.longitude + region.span.longitudeDelta / 2)];
     [rect addCoordinate:marker.position];

    GMSPolygon *polygon = [GMSPolygon polygonWithPath:rect];
    polygon.fillColor = [UIColor colorWithRed:0.25 green:0 blue:0 alpha:0.05];
    polygon.strokeColor = [UIColor blackColor];
    polygon.strokeWidth = 2;
    polygon.map = _map;
  }
}
];

The code above strokes some path around the marker, but this is not what I am looking for. Let us say my marker is in NY. How can I get all CLLocationCoordinate2D around the boundary of NY and add a polygon for it. Is there a readily available DB/Service which I can use.

user1191140
  • 1,559
  • 3
  • 18
  • 37
  • 2
    You can check out this question: http://stackoverflow.com/questions/9779978/ios-overlay-mkpolygon-data-for-all-u-s-states Not sure if it'll have all the data you need though. – Andy Jan 09 '15 at 23:37
  • Thank you. This is great to get me started. – user1191140 Jan 10 '15 at 18:37

0 Answers0