Closed Deykun closed 2 months ago
https://github.com/Deykun/maps/pull/17
The next step could be moving from images to old-school sprites. This approach would bypass fetching those 2,000 images individually and instead allow the user to fetch ex. 40 sprites with 50 coats each. This is actually a good case for sprites.
We still render 2,000 HTML nodes for those markers, but this is unavoidable, and I don't want to use canvas for it.
https://www.npmjs.com/package/join-images
It could potentially be used for sprites, but it requires creating all coats of arms at a specific ratio. Additionally, there will be extra padding, which creates an issue with mapping the actual size to the sprite, potentially triggering hover effects too early on a transparent background. It sounds like a nightmare.
I didn't want to use a canvas, but considering how unusable the Polish map is with 2.5k coats of arms and my ambition to create a one map for Europe, I'm forced to. The problem mentioned above can be solved with proper sprinting, and using a canvas will allow me to detect when someone clicks on a transparent part of a coat of arms. Additionally, we can detect all clicked coats of arms, not just the one on top.
Here are some advantages:
PoC has been merged already. https://github.com/Deykun/maps/pull/36
Above were the results for Poland, when it had approximately 2,100 coats of arms.
Here are the results for approximately 3,500 coats of arms from Poland, Estonia, and Finland with canvas used.
Sprites havenโt been added yet.
Map using sprites has been merged: https://github.com/Deykun/maps/pull/40
Results for 4,293 coats of arms:
Speed index has a huge bump.
The Polish map from the first comment using sprites without a canvas:
It loads a bit slower, but achieving performance over 75+ is still possible. Moreover, it no longer drops frames, which was a problem on Chrome.
Over 2,000 uncompressed coats of arms are fetched when a user enters the site to render the map.
The performance is so poor that it takes a very long time to get results and sometimes crashes. ๐
Expected result
We want to load all the coats of arms, but they can be resized.