Versions above 2.1.3 rerender map everytime for non primitive type in icon attribute #1785
Comments
|
@nmccready Creating deep copy of any model is fine. but while doing dirty check.. need to take care of primitive and non-primitive type. Comparison should also be deep. Can not compare two value directly because value can be object also.
|
Instead of copying and pasting code please use github URLS where the code lines are highlighted. It is way easier to get your point across. |
The following line does a direct comparison instead of deep comparison due to which non-primitive types are not working: |
I have used angular google map for displaying some geo information and used fit="true" attribute on my markers to display all markers in first view.
I had used icon specification as:
Due to my icon being a non-primitive datatype instead of the primitive specification as: item.icon="url_string", it raised a problem.
My problem was solved by using version 2.1.3
What I found out was that for non primitive data types, angular-google-maps version <=2.1.3 always created a reference to the original object, so whenever it checks that whether an object is changed or not, it got the same object so didn't rerender.
But in the versions above 2.1.3, instead of copying reference to the object, it copies the entire object so everytime it checks for icon, it assumes that the object is changed and tries to rerender entire map. So everytime i zoomed in to see a marker and clicked over it to see InfoWindow, it always zoomed out to the fitted position displaying all markers.
The lines from which I considered this to be a problem are:
version 2.1.3: this.clonedModel = _.extend({}, model); (in function MarkerChildModel.prototype.updateModel)
version 2.3.2: this.clonedModel = _.clone(this.model, true); (in function BasePolyChildModel(arg))
The text was updated successfully, but these errors were encountered: