@@ -59,6 +59,7 @@ angular.module("google-maps")
59
59
static : " ="
60
60
events : " ="
61
61
zIndex : " =zindex"
62
+ fit : " ="
62
63
63
64
link : (scope , element , attrs , mapCtrl ) ->
64
65
@@ -86,6 +87,7 @@ angular.module("google-maps")
86
87
geodesic : false
87
88
visible : true
88
89
static : false
90
+ fit : false
89
91
zIndex : 0
90
92
, (defaultValue , key ) ->
91
93
if angular .isUndefined (scope[key]) or scope[key] is null
@@ -100,9 +102,8 @@ angular.module("google-maps")
100
102
pathPoints = GmapUtil .convertPathPoints (scope .path )
101
103
polygon = new google.maps.Polygon (buildOpts (pathPoints))
102
104
# 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
106
107
107
108
if ! scope .static and angular .isDefined (scope .editable )
108
109
scope .$watch " editable" , (newValue , oldValue ) ->
@@ -154,6 +155,13 @@ angular.module("google-maps")
154
155
polygon .addListener eventName, getEventHandler (eventName) if scope .events .hasOwnProperty (eventName) and angular .isFunction (scope .events [eventName])
155
156
156
157
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
+ # )
157
165
158
166
# Remove polygon on scope $destroy
159
167
scope .$on " $destroy" , ->
0 commit comments