I have a collection of data points representing mountain peaks in the European Alps that I would like to showcase on a map. To prevent cluttering the user interface, I currently retrieve the highest peaks within the visible area of the map by sorting them based on elevation and selecting a specific number.
await prisma.mountain.findMany({
where: {
lat: { gt: lat_min, lt: lat_max },
lng: { gt: lng_min, lt: lng_max },
},
orderBy: {
elevation: "desc",
},
take: 20,
});
This approach works well when the map is zoomed in, but as the user zooms out, the results tend to cluster around regions with higher mountains quite quickly.
Is there a way to adjust my query to evenly distribute the results across the queried area?
I attempted to focus more on the center of the area by adjusting the bounds of my query as the user zooms out. However, this method did not yield satisfactory results when zoomed out extensively.