Optimisation suggestion
chris-eaton opened this issue · 3 comments
I have none of the tools setup to do a PR but I have noticed a performance problem that could be easily rectified.
Currently all markers
models are watched using $watch
. It would be far more efficient to watch them using $watchCollection
which would also allow using modelsbyref="true"
without having to replace the list every time you want to update it.
If it turns out $watch is best for most cases, an option for using $watchCollection
instead would be teriffic
Further to this.
If I modify my local copy to use $watchCollection
with modelsbyref="true"
... My digest cycles go from 300ms+ per cycle to around 100ms now. A huge improvement as this is for the entire page.
Good catch! I've digged into it too and caught this comment: https://github.com/angular-ui/angular-google-maps/blob/master/dist/angular-google-maps.js#L4186
Maybe he's using $watch
for markers on purpose as well? just a guess...
Yeah I saw that too actually. Thats for polylines though right? When I have static="true"
I have no performance issues with those. I tested this a fair amount locally and never saw an issues with $watchCollection
for markers being updated.