ev-map / EVMap

Android app to find electric vehicle charging stations - compatible with community databases such as GoingElectric.de and OpenChargeMap.org.
https://ev-map.app/
MIT License
205 stars 56 forks source link

Improve Marker clustering #307

Open arminfuerst opened 1 year ago

arminfuerst commented 1 year ago

An option to force distinct markers for each charging location would be nice or an option to define the minimal amount of markers to be merged. What I would like to achieve is to be able to screen the next possible charging locations on a long route. For example I am driving around 600-800km on a day (mainly highway), so I will have to charge 2 to 3 times. I'd like to filter for the stations I have a good tariff for (for example assume EnBW in Germany) and I am looking for reasonable stops on A3 from Passau to Frankfurt. Currently, this looks like this screenshot: image For example, I see 4 charging locations near Regensburg. When I zoom in, it seems as only one of those 4 charging locations is really located close to the A3: image If I zoom in even more, I can recognize, that there are 2 charging locations (instead of only 1) on the A3: image But this zoom-level is far to much detail to gain an overview for my route. My typical use case is to search for the next reasonable charging location during my current charging, that's why it would be helpful to do this with this great app.

johan12345 commented 1 year ago

In general, marker clustering is required when many markers are shown on the map to keep the map from being laggy (see also, e.g., #285) or even crashing. So we definitely cannot add an option to completely disable clustering.

To further improve the performance (especially in terms of loading times), we sometimes perform the clustering on the server side if the data source (GoingElectric) supports it - in this case we don't have much control over the clustering algorithm except for one parameter (clusterDistance) that we can set. I already did some tweaking of this earlier, but it's hard to get it right for all cases (if it's too low, the map is too cluttered when there are many chargers, and if it's too high we run into situations like the one you described when there are few chargers).

Above a certain zoom level, or if the data source doesn't support server-side clustering (OpenChargeMap), we do switch to client-side clustering and would have a bit more control about the clustering algorithm and its parameters. So this case could definitely be optimized a bit more. But still, as I said, it's always a tradeoff and hard to get right for all cases...

arminfuerst commented 1 year ago

When creating the suggestion, I was aware of the fact that a "misuse" results in a laggy responsiveness. That's why my suggestion included the idea to solve this by defining a minimal amount of markers needed to be merged. Since this might be unclear, I try to explain: Assume, I define "5" as a minimal amount. The generation remains unchanged and if a merging would be done but the amount to markers is less then 5, they are not merged. In my first screenshot this would result in just two merged markers (both near Munich) while all others are displayed distinctively. I had the idea based on the map in Goingelectric where there is an option not to merge the markers. I would be happy to discuss pros and cons of alternate ideas. For my use case, probably adding a filter to only show locations being less than x km away from highways would also simplify my use case.