googlearchive / js-marker-clusterer

A marker clustering library for the Google Maps JavaScript API v3.
https://googlemaps.github.io/js-marker-clusterer/docs/reference.html
Apache License 2.0
1.28k stars 768 forks source link

Marker clustering with overlay view (custom markers)? #117

Open kylegillen opened 7 years ago

kylegillen commented 7 years ago

Hi. Great lib!

Not sure if here would be the best place to ask or over in the gmaps.js repo, but figured I'd take a shot.

I was wondering if anyone knew how to go about extending google.maps.OverlayView() so that gmaps MarkerClusterer constructor could cluster them as it does with standard markers?

I saw this post on SO: http://stackoverflow.com/questions/8297456/google-maps-v3-clustering-with-custom-markers but when I attempted to extend the gmaps implementation of OverlayView, these methods were never called.

  overlay.setVisible = function(visible) {
   // custom implementation
  }

  overlay.getPosition = function() {
    return this.position;
  }

So I assume gmaps goes about its own way of abstracting the drawing of clusters also?

Anyways, any help is much appreciated.

Thanks.

maximou4391 commented 7 years ago

I nextriot, I just tried and it worked well, but now my question is, can we put custom html div instead of the images :) that would be cool, I will try. Maxime.

dave4jr commented 7 years ago

I'm trying to do the same thing. I'm sure a ton of people are having this same issue. I think the RichMarker solved this issue but there's no longer support for it, not sure why, can't find anything on that subject.

maximou4391 commented 7 years ago

Hi dave4jr, I manage do use overlay with the cluster library and also to display custom html inside the overlays. Ping me (maximou4391@hotmail.fr) if you need help.

maximou4391 commented 7 years ago

Hi @dave4jr,

I used this example http://humaan.com/custom-html-markers-google-maps with this one you can put everything you want in innerHTML and that's pretty much it. You can also use it in typescript with proper typings.

weijyewang commented 6 years ago

@maximou4391 I tried the same approach like @dave4jr and @nextriot and I'm facing the same issue as well. How did you make it work? I'm on Angular 6 and Typescript