File tree Expand file tree Collapse file tree 4 files changed +82
-4
lines changed
Expand file tree Collapse file tree 4 files changed +82
-4
lines changed Original file line number Diff line number Diff line change @@ -503,6 +503,7 @@ export abstract class PolygonBase extends ShapeBase implements Polygon {
503503 public shape : string = 'polygon' ;
504504 public _map : any ;
505505 public _points : Array < PositionBase > ;
506+ public _holes : Array < Array < PositionBase > > ;
506507 public strokeWidth : number ;
507508 public strokeColor : Color ;
508509 public fillColor : Color ;
@@ -534,7 +535,36 @@ export abstract class PolygonBase extends ShapeBase implements Polygon {
534535 return this . _points . slice ( ) ;
535536 }
536537
538+ addHole ( hole : PositionBase [ ] ) : void {
539+ this . _holes . push ( hole ) ;
540+ this . reloadHoles ( ) ;
541+ }
542+
543+ addHoles ( holes : PositionBase [ ] [ ] ) : void {
544+ this . _holes = this . _holes . concat ( holes ) ;
545+ this . reloadHoles ( ) ;
546+ }
547+
548+ removeHole ( hole : PositionBase [ ] ) : void {
549+ var index = this . _holes . indexOf ( hole ) ;
550+ if ( index > - 1 ) {
551+ this . _holes . splice ( index , 1 ) ;
552+ this . reloadHoles ( ) ;
553+ }
554+ }
555+
556+ removeAllHoles ( ) : void {
557+ this . _holes . length = 0 ;
558+ this . reloadHoles ( ) ;
559+ }
560+
561+ getHoles ( ) : Array < Array < PositionBase > > {
562+ return this . _holes . slice ( ) ;
563+ }
564+
537565 public abstract reloadPoints ( ) : void ;
566+
567+ public abstract reloadHoles ( ) : void ;
538568}
539569
540570export class CircleBase extends ShapeBase implements Circle {
Original file line number Diff line number Diff line change @@ -417,6 +417,7 @@ export class MapView extends MapViewBase {
417417
418418 addPolygon ( shape : Polygon ) {
419419 shape . loadPoints ( ) ;
420+ shape . loadHoles ( ) ;
420421 shape . android = this . gMap . addPolygon ( shape . android ) ;
421422 this . _shapes . push ( shape ) ;
422423 }
@@ -985,6 +986,7 @@ export class Polygon extends PolygonBase {
985986 super ( ) ;
986987 this . android = new com . google . android . gms . maps . model . PolygonOptions ( ) ;
987988 this . _points = [ ] ;
989+ this . _holes = [ ] ;
988990 }
989991
990992 get clickable ( ) {
@@ -1031,6 +1033,18 @@ export class Polygon extends PolygonBase {
10311033 }
10321034 }
10331035
1036+ loadHoles ( ) : void {
1037+ if ( ! this . _isReal ) {
1038+ this . _holes . forEach ( ( hole : Position [ ] ) => {
1039+ var points = new java . util . ArrayList ( ) ;
1040+ hole . forEach ( ( point : Position ) => {
1041+ points . add ( point . android ) ;
1042+ } ) ;
1043+ this . _android . addHole ( points ) ;
1044+ } ) ;
1045+ }
1046+ }
1047+
10341048 reloadPoints ( ) : void {
10351049 if ( this . _isReal ) {
10361050 var points = new java . util . ArrayList ( ) ;
@@ -1041,6 +1055,20 @@ export class Polygon extends PolygonBase {
10411055 }
10421056 }
10431057
1058+ reloadHoles ( ) : void {
1059+ if ( this . _isReal ) {
1060+ var holes = new java . util . ArrayList ( ) ;
1061+ this . _holes . forEach ( ( hole ) => {
1062+ var points = new java . util . ArrayList ( ) ;
1063+ hole . forEach ( ( point ) => {
1064+ points . add ( point . android ) ;
1065+ } ) ;
1066+ holes . add ( points ) ;
1067+ } ) ;
1068+ this . _android . setHoles ( holes ) ;
1069+ }
1070+ }
1071+
10441072 get strokeWidth ( ) {
10451073 return this . _android . getStrokeWidth ( ) ;
10461074 }
Original file line number Diff line number Diff line change @@ -196,7 +196,12 @@ export class Polygon extends Shape {
196196 public addPoints ( shapes : Position [ ] ) : void ;
197197 public removePoint ( shape : Position ) : void ;
198198 public removeAllPoints ( ) : void ;
199+ public addHole ( hole : Position [ ] ) : void ;
200+ public addHoles ( hole : Position [ ] [ ] ) : void ;
201+ public removeHole ( hole : Position [ ] ) : void ;
202+ public removeAllHoles ( ) : void ;
199203 public getPoints ( ) : Array < Position > ;
204+ public getHoles ( ) : Array < Array < Position > > ;
200205}
201206
202207export class Circle extends Shape {
Original file line number Diff line number Diff line change @@ -812,6 +812,7 @@ export class Polygon extends PolygonBase {
812812 super ( ) ;
813813 this . _ios = GMSPolygon . new ( ) ;
814814 this . _points = [ ] ;
815+ this . _holes = [ ] ;
815816 }
816817
817818 get clickable ( ) {
@@ -830,20 +831,34 @@ export class Polygon extends PolygonBase {
830831 this . _ios . zIndex = value ;
831832 }
832833
833-
834-
835834 loadPoints ( ) : void {
836835 var points = GMSMutablePath . new ( ) ;
837- this . _points . forEach ( function ( point ) {
836+ this . _points . forEach ( ( point : Position ) => {
838837 points . addCoordinate ( point . ios ) ;
839- } . bind ( this ) ) ;
838+ } ) ;
840839 this . _ios . path = points ;
841840 }
842841
842+ loadHoles ( ) : void {
843+ var holes = [ ] ;
844+ this . _holes . forEach ( ( hole : Position [ ] ) => {
845+ var points = GMSMutablePath . new ( ) ;
846+ hole . forEach ( ( point : Position ) => {
847+ points . addCoordinate ( point . ios ) ;
848+ } ) ;
849+ holes . push ( points ) ;
850+ } ) ;
851+ this . _ios . holes = holes ;
852+ }
853+
843854 reloadPoints ( ) : void {
844855 this . loadPoints ( ) ;
845856 }
846857
858+ reloadHoles ( ) : void {
859+ this . loadHoles ( ) ;
860+ }
861+
847862 get strokeWidth ( ) {
848863 return this . _ios . strokeWidth ;
849864 }
You can’t perform that action at this time.
0 commit comments