Skip to content
This repository was archived by the owner on Nov 30, 2018. It is now read-only.

Commit 32086ad

Browse files
committed
fix(marker): markers now update on model changes
motivation: markers update relies on a comparison between a cached (cloned) version of the model and the reference model. Prior to this commit, the cached model is built using a shallow copy of the reference model (using `_.extends`). Thus, both cached and reference model properties are always identical and model properties changes, e.g. coordinates, are not reflected on the map. In this commit, the cached model is built using a *deep-copy* using `_.clone(model,true)`. solves issue #1350
1 parent b8fe176 commit 32086ad

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/coffee/directives/api/models/child/marker-child-model.coffee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ angular.module('uiGmapgoogle-maps.directives.api.models.child')
2323
@trackModel = true, @needRedraw = false) ->
2424
#where @model is a reference to model in the controller scope
2525
#clonedModel is a copy for comparison
26-
@clonedModel = _.extend({},@model)
26+
@clonedModel = _.clone(@model,true)
2727
@deferred = uiGmapPromise.defer()
2828
_.each @keys, (v, k) =>
2929
keyValue = @keys[k]
@@ -80,7 +80,7 @@ angular.module('uiGmapgoogle-maps.directives.api.models.child')
8080
@needRedraw = true
8181

8282
updateModel: (model) =>
83-
@clonedModel = _.extend({},model) #changed from _.clone(model, true) eliminates lodash dep (so you can use underscore)
83+
@clonedModel = _.clone(model,true) #changed from _.clone(model, true) eliminates lodash dep (so you can use underscore)
8484
@setMyScope 'all', model, @model
8585

8686
renderGMarker: (doDraw = true, validCb) ->

src/coffee/directives/api/models/child/window-child-model.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ angular.module('uiGmapgoogle-maps.directives.api.models.child')
199199
@scope.$destroy()
200200

201201
updateModel: (model) =>
202-
@clonedModel = _.extend({},model)
202+
@clonedModel = _.clone(model,true)
203203
_.extend(@model, @clonedModel)
204204

205205
WindowChildModel

0 commit comments

Comments
 (0)