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

Commit

Permalink
fix(marker): markers now update on model changes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
quentinlampin committed Jun 12, 2015
1 parent b8fe176 commit 32086ad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ angular.module('uiGmapgoogle-maps.directives.api.models.child')
@trackModel = true, @needRedraw = false) ->
#where @model is a reference to model in the controller scope
#clonedModel is a copy for comparison
@clonedModel = _.extend({},@model)
@clonedModel = _.clone(@model,true)
@deferred = uiGmapPromise.defer()
_.each @keys, (v, k) =>
keyValue = @keys[k]
Expand Down Expand Up @@ -80,7 +80,7 @@ angular.module('uiGmapgoogle-maps.directives.api.models.child')
@needRedraw = true

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

renderGMarker: (doDraw = true, validCb) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ angular.module('uiGmapgoogle-maps.directives.api.models.child')
@scope.$destroy()

updateModel: (model) =>
@clonedModel = _.extend({},model)
@clonedModel = _.clone(model,true)
_.extend(@model, @clonedModel)

WindowChildModel
Expand Down

0 comments on commit 32086ad

Please sign in to comment.