Skip to content

Commit 4c51d7c

Browse files
author
masashiGMS
committed
feature request #683 (iOS)
1 parent ef3d9e2 commit 4c51d7c

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/ios/GoogleMaps/Polygon.m

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,26 @@ -(void)createPolygon:(CDVInvokedUrlCommand *)command
3232
// Create the polygon, and assign it to the map.
3333
GMSPolygon *polygon = [GMSPolygon polygonWithPath:path];
3434
polygon.title = @"polygon";
35-
35+
if ([json valueForKey:@"holes"]) {
36+
NSArray *holes = [json objectForKey:@"holes"];
37+
NSArray *latLngArray;
38+
NSDictionary *latLng;
39+
int j;
40+
NSMutableArray *holePaths = [NSMutableArray array];
41+
42+
43+
for (i = 0; i < holes.count; i++) {
44+
latLngArray = [holes objectAtIndex:i];
45+
GMSMutablePath *holePath = [GMSMutablePath path];
46+
for (j = 0; j < latLngArray.count; j++) {
47+
latLng = [latLngArray objectAtIndex:j];
48+
[holePath addLatitude:[[latLng objectForKey:@"lat"] floatValue] longitude:[[latLng objectForKey:@"lng"] floatValue]];
49+
}
50+
[holePaths addObject:holePath];
51+
}
52+
polygon.holes = holePaths;
53+
}
54+
3655
if ([[json valueForKey:@"visible"] boolValue]) {
3756
polygon.map = self.mapCtrl.map;
3857
}

www/googlemaps-cdv-plugin.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,10 @@ App.prototype.addPolyline = function(polylineOptions, callback) {
11281128
App.prototype.addPolygon = function(polygonOptions, callback) {
11291129
var self = this;
11301130
polygonOptions.points = polygonOptions.points || [];
1131+
polygonOptions.holes = polygonOptions.holes || [];
1132+
if (polygonOptions.holes.length > 0 && !Array.isArray(polygonOptions.holes[0])) {
1133+
polygonOptions.holes = [polygonOptions.holes];
1134+
}
11311135
polygonOptions.strokeColor = HTMLColor2RGBA(polygonOptions.strokeColor || "#FF000080", 0.75);
11321136
if (polygonOptions.fillColor) {
11331137
polygonOptions.fillColor = HTMLColor2RGBA(polygonOptions.fillColor, 0.75);

0 commit comments

Comments
 (0)