inocan-group / vue3-google-map

A set of composable components for easy use of Google Maps in your Vue 3 projects.
https://vue3-google-map.com
MIT License
280 stars 57 forks source link

How to add "MarkerClusterer"? #44

Closed asoltani927 closed 2 years ago

asoltani927 commented 3 years ago

How can I add "MarkerClusterer" to map instance?

HusamElbashir commented 3 years ago

This is unfortunately not supported yet. But considering how popular this feature seems to be I'll look into adding it when I have some spare time.

sagardspeed2 commented 3 years ago

@asoltani927 thanks for adding this request, I also need this functionality in my project. but it seems that it is not supported. @HusamIbrahim can you please share any status related this ?

@HusamIbrahim can you please mention that, what changes we need to make for use this functionality with this package ?

vesper8 commented 2 years ago

@HusamIbrahim This package needs cluster support so badly.... please can you add it?

HusamElbashir commented 2 years ago

I'll hopefully take a stab at it this weekend

HusamElbashir commented 2 years ago

Added in v0.11.0. Basic syntax is:

<MarkerCluster>
  <Marker v-for="(location, i) in locations" :options="{ position: location }" :key="i" />
</MarkerCluster>

Documentation to be added soon

vesper8 commented 2 years ago

@HusamIbrahim Thanks for adding this!

I've given it a try and can confirm it is working with regular markers. However it isn't working with custom markers from the vue3-gmap-custom-marker library

With regular markers I see the clusters but with the custom markers, which are otherwise working, when I add your MarkerCluster then all my custom markers just disappear

HusamElbashir commented 2 years ago

Hey @vesper8

So the custom markers are built with an OverlayView whereas the MarkerClusterer library we're using is expecting Marker's. Seems that the only way to get this to work is having the custom markers implement the Marker interface that MarkerClusterer expects. Reference: https://stackoverflow.com/questions/8297456/google-maps-v3-clustering-with-custom-markers

My plan is to add custom markers natively in this library seeing as it's such a popular feature. I'll hopefully have it support clustering as well.

vesper8 commented 2 years ago

@HusamIbrahim That would be great if you could add custom markers natively.

Previously I was using gmap-vue in combination with vue2-gmap-custom-marker, and since gmap-vue has issues with their native clusters, I was actually pulling in the cluster from vue2-google-maps. Seems a bit chaotic.. yet somehow it just worked anyway.

Based on that, I would imagine that it would be possible to make your clusters work with vue3-gmap-custom-marker, or maybe that author would need to add support. Either way, as much as I need the cluster functionality, I cannot give up my custom markers so I will have to wait some more until this is possible.

Many thanks!

HusamElbashir commented 2 years ago

@vesper8 These libraries being forks might explain the compatibility in that case 🙂

I would try reaching out to vue3-gmap-custom-marker's author to see if he can make it work. The readme points to the lack of clustering support in this library but leaves open the possibility of adding support on their end: https://github.com/eregnier/vue3-gmap-custom-marker#features

Again this is only if you need it urgently. I'll have custom markers implemented natively in this library eventually.

vesper8 commented 2 years ago

@HusamIbrahim I bet you could have custom markers implemented in 30 minutes ;-)

HusamElbashir commented 2 years ago

@vesper8 Custom markers added in v0.12.0 https://github.com/inocan-group/vue3-google-map#custom-marker