08 · Symbols with collision
Ten midtown landmarks laid out by the library's CollisionIndex: the most important first, and any that would overlap one already placed left out. Zoom out to watch them drop away.
Open it full screen · Edit and run it · Full source: 08-symbols.ts
import { CollisionIndex } from 'ts-maps/symbols'
const index = new CollisionIndex({ width, height, cellSize: 64 })
for (const poi of byPriority) {
if (index.tryInsert({ minX, minY, maxX, maxY, priority: poi.priority }))
new Marker([poi.lat, poi.lng], { icon }).addTo(map)
}