File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -129,7 +129,19 @@ const memoCountStyle = (getMarker: GetMarkerFunction): GetMarkerFunction => {
129129 }
130130}
131131
132- const getStyleFunction : GetMarkerFunction = ( style , multi ) =>
132+ /**
133+ * The map became a little laggy due to constant re-generation of styles.
134+ * This memoization function optimises this issue by reusing styles.
135+ * */
136+ const memoizeStyle = ( getMarker : GetMarkerFunction ) : GetMarkerFunction => {
137+ const memoizedCountStyle = memoCountStyle ( getMarker )
138+ const memoizedStyle = memoStyle ( getMarker )
139+ return ( style , count , displayFeatureCount ) =>
140+ displayFeatureCount
141+ ? memoizedCountStyle ( style , count , displayFeatureCount )
142+ : memoizedStyle ( style , count , displayFeatureCount )
143+ }
144+
133145 new Style ( {
134146 image : new Icon ( {
135147 src : ( multi ? makeMultiMarker : makeMarker ) ( style ) ,
You can’t perform that action at this time.
0 commit comments