francoisromain / leaflet-markers-canvas

A Leaflet plugin to render many markers in a canvas instead of the DOM
GNU Affero General Public License v3.0
42 stars 15 forks source link

Fixed markers disappearing on the map's edges (see description) #16

Open matafokka opened 2 years ago

matafokka commented 2 years ago

Hello! Currently if you'll move the map just a bit, you can see markers randomly appear and disappear when they're near map's edges.

The problem is that marker's visibility is checked only by its LatLng. The fix is to check bounds instead.

There're two ways to implement it:

  1. Switch from RBush to linear search. This is what I went with.
  2. Add marker's corners to the tree and track them. This will result in ~4x slowdown.

If you'll merge this PR, please, take a look at the commits. I changed stuff like package name and links in case there'll be no activity, and I'll want to publish it on npm. You might be better off just copying the code.