Skip to content

Commit fc6811f

Browse files
author
Rick Huizinga
committed
Added preliminary support for undocumented fit attribute
1 parent c9bbf4f commit fc6811f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/coffee/directives/polygon.coffee

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ angular.module("google-maps")
5959
static: "="
6060
events: "="
6161
zIndex: "=zindex"
62+
fit: "="
6263

6364
link: (scope, element, attrs, mapCtrl) ->
6465

@@ -86,6 +87,7 @@ angular.module("google-maps")
8687
geodesic: false
8788
visible: true
8889
static: false
90+
fit: false
8991
zIndex: 0
9092
, (defaultValue, key) ->
9193
if angular.isUndefined(scope[key]) or scope[key] is null
@@ -100,9 +102,8 @@ angular.module("google-maps")
100102
pathPoints = GmapUtil.convertPathPoints(scope.path)
101103
polygon = new google.maps.Polygon(buildOpts(pathPoints))
102104
# The fit attribute is undocumented as it currently does not
103-
# properly work when changes to the path are made. arraySync
104-
# needs to be upgraded to support this.
105-
GmapUtil.extendMapBounds map, pathPoints if isTrue(attrs.fit)
105+
# properly work when changes to the path are made.
106+
GmapUtil.extendMapBounds map, pathPoints if scope.fit
106107

107108
if !scope.static and angular.isDefined(scope.editable)
108109
scope.$watch "editable", (newValue, oldValue) ->
@@ -154,6 +155,13 @@ angular.module("google-maps")
154155
polygon.addListener eventName, getEventHandler(eventName) if scope.events.hasOwnProperty(eventName) and angular.isFunction(scope.events[eventName])
155156

156157
arraySyncer = arraySync(polygon.getPath(), scope, "path")
158+
159+
# To properly support the undocumented fit attribute,
160+
# array-sync needs to be upgraded to have an optional pathChanged callback
161+
# function that is called with the path points whenever they have been changed.
162+
#arraySyncer = arraySync(polygon.getPath(), scope, "path", (pathPoints) ->
163+
# GmapUtil.extendMapBounds map, pathPoints if scope.fit
164+
#)
157165

158166
# Remove polygon on scope $destroy
159167
scope.$on "$destroy", ->

0 commit comments

Comments
 (0)