Skip to content

Commit ae17cf3

Browse files
committed
Fix this; was creating polylines!
1 parent cd111ec commit ae17cf3

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/coffee/directives/polygon.coffee

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ angular.module("google-maps").directive "polygon", ["$log", "$timeout", ($log, $
7070
replace: true
7171
scope:
7272
path: "=path"
73-
stroke: "=stroke"
73+
stroke: "=stroke",
74+
fill: "=fill",
7475
clickable: "="
7576
draggable: "="
7677
editable: "="
@@ -82,10 +83,10 @@ angular.module("google-maps").directive "polygon", ["$log", "$timeout", ($log, $
8283

8384
# Validate required properties
8485
if angular.isUndefined(scope.path) or scope.path is null or scope.path.length < 2 or not validatePathPoints(scope.path)
85-
$log.error "polyline: no valid path attribute found"
86+
$log.error "polygon: no valid path attribute found"
8687
return
8788

88-
# Wrap polyline initialization inside a $timeout() call to make sure the map is created already
89+
# Wrap polygon initialization inside a $timeout() call to make sure the map is created already
8990
$timeout ->
9091
map = mapCtrl.getMap()
9192
pathPoints = convertPathPoints(scope.path)
@@ -95,6 +96,8 @@ angular.module("google-maps").directive "polygon", ["$log", "$timeout", ($log, $
9596
strokeColor: scope.stroke and scope.stroke.color
9697
strokeOpacity: scope.stroke and scope.stroke.opacity
9798
strokeWeight: scope.stroke and scope.stroke.weight
99+
fillColor: scope.fill and scope.fill.color
100+
fillOpacity: scope.fill and scope.fill.opacity
98101
)
99102
angular.forEach
100103
clickable: true
@@ -108,24 +111,24 @@ angular.module("google-maps").directive "polygon", ["$log", "$timeout", ($log, $
108111
else
109112
opts[key] = scope[key]
110113

111-
polyline = new google.maps.Polyline(opts)
114+
polygon = new google.maps.Polygon(opts)
112115
extendMapBounds map, pathPoints if isTrue(attrs.fit)
113116
if angular.isDefined(scope.editable)
114117
scope.$watch "editable", (newValue, oldValue) ->
115-
polyline.setEditable newValue
118+
polygon.setEditable newValue
116119

117120
if angular.isDefined(scope.draggable)
118121
scope.$watch "draggable", (newValue, oldValue) ->
119-
polyline.setDraggable newValue
122+
polygon.setDraggable newValue
120123

121124
if angular.isDefined(scope.visible)
122125
scope.$watch "visible", (newValue, oldValue) ->
123-
polyline.setVisible newValue
126+
polygon.setVisible newValue
124127

125128
pathSetAtListener = undefined
126129
pathInsertAtListener = undefined
127130
pathRemoveAtListener = undefined
128-
polyPath = polyline.getPath()
131+
polyPath = polygon.getPath()
129132
pathSetAtListener = google.maps.event.addListener(polyPath, "set_at", (index) ->
130133
value = polyPath.getAt(index)
131134
return unless value
@@ -152,7 +155,7 @@ angular.module("google-maps").directive "polygon", ["$log", "$timeout", ($log, $
152155
oldArray = polyline.getPath()
153156
if newArray isnt oldArray
154157
if newArray
155-
polyline.setMap map
158+
polygon.setMap map
156159
i = 0
157160
oldLength = oldArray.getLength()
158161
newLength = newArray.length
@@ -173,12 +176,12 @@ angular.module("google-maps").directive "polygon", ["$log", "$timeout", ($log, $
173176
else
174177

175178
# Remove polyline
176-
polyline.setMap null
179+
polygon.setMap null
177180
), true
178181

179182
# Remove polyline on scope $destroy
180183
scope.$on "$destroy", ->
181-
polyline.setMap null
184+
polygon.setMap null
182185
pathSetAtListener()
183186
pathSetAtListener = null
184187
pathInsertAtListener()
@@ -187,4 +190,4 @@ angular.module("google-maps").directive "polygon", ["$log", "$timeout", ($log, $
187190
pathRemoveAtListener = null
188191

189192

190-
]
193+
]

0 commit comments

Comments
 (0)