dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.21k stars 1.74k forks source link

Provide clustering for map pins #11811

Open smitha-cgi opened 1 year ago

smitha-cgi commented 1 year ago

Description

Showing thousands of pins on the map works, but it takes a long time to render them all, and the map is then extremely cluttered. Pins should be grouped together in clusters which are then only expanded into pins as the map is zoomed in or out.

Could potentially be done using this on Android and this on iOS. I have written something custom for my MAUI app on Android (storing list of locations in memory and then dynamically painting cluster markers on the map when camera changes), happy to provide some example code if someone can work out how to get it to fit into MAUI and do the same thing on iOS.

Public API Changes

Something like this:

map.ClusterShapeTextColor = Colors.White; map.ClusterShapeColor = Colors.IndianRed; map.ClusterShapeRadius = 20; map.ClusterDistance = Distance.FromKilometers(5); map.IsClustering = true;

This is assuming that the cluster object is a simple circle with a number inside it that indicates how many locations it represents.

Intended Use-Case

Show thousands of locations on a map without it getting overloaded trying to draw individual pins for each location

Rabosa616 commented 1 year ago

Hi @PureWeen , @jsuarezruiz and @jfversluis

Is there any news on this feature? Is a very important feature when you work with maps in real production applications, you are not gonna show hundreds/thousands of pins on the map.

This is exposed by Maps providers and their SDK's Android: https://developers.google.com/maps/documentation/android-sdk/utility/marker-clustering iOS: https://developer.apple.com/documentation/mapkit/mkannotationview/decluttering_a_map_with_mapkit_annotation_clustering

So by exposing it also the CommunityToolkit.Maps would be able to provide it for windows devices.

Bing Maps: https://learn.microsoft.com/en-us/bingmaps/v8-web-control/map-control-concepts/clustering-module-examples/basic-clustering-example

This feature will save a lot of time and will make maps more productions ready control than current just show demo control

jfversluis commented 1 year ago

Unfortunately there is nothing to share at this moment.

What could help move this forward is think a bit more about what a unified API might look like to you and share that. Maybe even a proof of concept or a PR providing the basic functionality of this.

I'm afraid I don't have any timeline for this right now.

Rabosa616 commented 1 year ago

I would propose the public api that was proposed by @smitha-cgi in this issue

Public API Changes Something like this:

map.ClusterShapeTextColor = Colors.White; map.ClusterShapeColor = Colors.IndianRed; map.ClusterShapeRadius = 20; map.ClusterDistance = Distance.FromKilometers(5); map.IsClustering = true;

Then Maui code internally should manage which collection on each platform will contain the pins depending the IsClustering value.

For iOS I see that the needed classes are in MAUI source code but for Android I think the package Xamarin.GoogleServices.Map does no include the Android Maps cluster package so needs a refactor on that component to expose them.

nichojo89 commented 8 months ago

Our team is also requiring map clustering in our .NET MAUI application

iamalexmang commented 8 months ago

Any updates on this?

magtimmermans commented 8 months ago

Any updates? The current implementation is a minimum version.

puonghuei commented 7 months ago

Any updates for this feature? Appreciate it if there is an update for this.

iamalexmang commented 7 months ago

Any updates (on this feature or any other, frankly) would be much appreciated!

SupermindPT commented 4 months ago

Did someone accomplish to integrate map pins clusters using native Android Java Binding Libraries ?

MarkEvans8 commented 2 months ago

I also need this for a commercial application with thousands of pins. Is there any way to deal with lots of locations using native mapping on Android and iOS using Maui?

Rabosa616 commented 2 months ago

Hi @jamesmontemagno, is there any update on when issue #11811 will be implemented? In production applications that use maps, displaying 1000 pins at once is not ideal. It would be great to have a solution for this.

SupermindPT commented 2 months ago

Hi @jamesmontemagno, is there any update on when issue #11811 will be implemented? In production applications that use maps, displaying 1000 pins at once is not ideal. It would be great to have a solution for this.

I don't think it will ever be implemented by the MAUI Team. It will be the same it was with Xamarin, someone with enough free time will create a nuget package for it.

themronion commented 1 month ago

Hey guys, if u need it u can use https://github.com/themronion/Maui.GoogleMaps. Although keep in mind, only iOS and Android are supported and it uses Google maps on iOS as well.

SupermindPT commented 1 month ago

Hey guys, if u need it u can use https://github.com/themronion/Maui.GoogleMaps. Although keep in mind, only iOS and Android are supported and it uses Google maps on iOS as well.

That is a great contribution @themronion ! Great work