nlaplante/angular-google-maps — pull request #307 by rickhuizinga (2014-03-14 23:06:06+00:00)
Title: Dramatically improved performance for large polygons

Added static attribute to polygon directive. It dramatically improves performance of polygons, especially those containing thousands of points.

Setting the static attribute to true implies that the polygon's points are static (do not change). The performance benefit comes from the fact that the directive does not need to perform deep watch on every polygon co-ordinate for every Angular digest cycle. (Although a watch is still performed on the path attribute for changes by reference so that the entire polygon can still be changed.) In addition, because the polygon is static, it implies that it is not editable so that edits from Google Maps do not need to be watched.

Without the static attribute on a map with multiple polygons containing 25,000+ coordinates, the browser would simply consume 100% CPU, the browser tab would be frozen and Chrome would eventually emit VM errors. On smaller polygons (~2500 coordinates), the polygon directive would simply be slow and take about 3 seconds to render.

With the static attribute set to true, the case of the multiple polygons containing 25,000+ coordinates, the polygons are displayed almost instantly.

In terms of documentation:

1) Setting the static attribute to true implies the polygon is static and its contents do not change. As a result, this implies that the polygon is not editable and thus overrides any setting of the editable attribute. Note: the path attribute can still be changed, but it will only be watched for a change of object by reference - not by deep inspection of every coordinate.