angular-google-maps icon indicating copy to clipboard operation
angular-google-maps copied to clipboard

Optimisation suggestion

Open chris-eaton opened this issue 7 years ago • 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

chris-eaton avatar Feb 06 '17 10:02 chris-eaton

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.

chris-eaton avatar Feb 06 '17 14:02 chris-eaton

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...

markmssd avatar Feb 08 '17 04:02 markmssd

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.

chris-eaton avatar Feb 08 '17 09:02 chris-eaton