You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using this library in a project with a few hundred customMarkers and noticed that the app is very laggy when zooming in and out on the map. When analyzing with devtools I noticed that on each zoom event the browser was forced to recalculate the layout and styling for each of my custom markers which is slow.
The reflow originates from the draw method in src/utils/index.ts.
// src/utils/index.tsdraw(){if(!this.element)return;constoverlayProjection=this.getProjection();constpoint=overlayProjection?.fromLatLngToDivPixel(this.getPosition());if(point){this.element.style.position="absolute";constheight=this.element.offsetHeight;// <-- THIS LINEconstwidth=this.element.offsetWidth;// <-- AND THIS LINE
let x: number,y: number;switch(this.opts.anchorPoint){
If you check this link you can see that accessing element.offsetHeight and element.offsetWidth forces a reflow.
This issue can be solved by including a size option for the custom markers which can be used instead of the element attributes.
I am using this library in a project with a few hundred customMarkers and noticed that the app is very laggy when zooming in and out on the map. When analyzing with devtools I noticed that on each zoom event the browser was forced to recalculate the layout and styling for each of my custom markers which is slow.
The reflow originates from the draw method in
src/utils/index.ts
.If you check this link you can see that accessing
element.offsetHeight
andelement.offsetWidth
forces a reflow.This issue can be solved by including a
size
option for the custom markers which can be used instead of the element attributes.I have solved it this way in a fork I made, it improved map performance in my app by 90%. Submitting a PR soon.
The text was updated successfully, but these errors were encountered: