block by enjalot eb331a84b3ef877aa6b0004308abfac9

dots on a map: quadtree circle

Full Screen

This example shows how to select points close to the mouse using a quadtree on the longitude,latitude coordinates of our data.

The advantage of calculating the quadtree using lng/lat is that you don’t need to recompute the quadtree when the projection has changed (due to zooming and panning). The disadvantage is that the distortion of the projection means you wont always get a nice circle (you can see the ellipse get longer the further north you go).

There is commented out code at line 130 which allows you to create a circular selection by deriving individual radii for longitude and latitude from a set pixel value. The advantage here is a nice circle, while the disadvantage is that the circle stays the same size at all zoom levels (meaning you could be selecting exponentially more points while zoomed out).

Adjusting the pixel radius by zoom level is an exercise left for the reader ;)

Built with blockbuilder.org

forked from enjalot‘s block: dots on a map: setup-gl

forked from enjalot‘s block: dots on a map: The Counted

forked from enjalot‘s block: dots on a map: The Counted

forked from enjalot‘s block: dots on a map: quadtree

index.html