Google Maps markerClusterer + InfoBubble - selectively display or hide based on cluster true or false

北城以北 提交于 2019-12-11 21:23:53

问题


I have markerCluster working fine with InfoBubbles (a utility for gmaps v3).

It looks like this:

Last little improvement here is to make the infoBubbles disappear IF the markers have been clustered. You can see the (3) in the image and you see some phantom infoBubbles floating nearby but no markers underneath them.

The code says:

infoBubble[i] = new InfoBubble({
content: '<div id="msg" class="map-text" style="font-size:13px">'+res[i].job.start_time+" -"+res[i].job.end_time+'</div>',                                                  hideCloseButton: true,
padding: 2,
disableAutoPan: true,
});
infoBubble[i].open(map,marker);

My idea is to wrap the last line, infoBubble[i], into an if block that says something to the effect of "if marker, open" where it's marker or cluster.

I just can't figure out the right syntax to describe this condition. Any ideas?

UPDATE

The marker clusterer is exceedingly simple:

 var markerCluster = new MarkerClusterer(map, markers, {
            minimumClusterSize: 3,
        });

I think the answer is to say something like "if infoBubble grid > 60, infoBubble.open"k

60 being the default grid size of the marker clusterer, within this boundary is when the heat marker will appear and the marker itself disappears. So it stands to reason that I can apply the same logic to the infoBubbles themselves "faking" their disappearance.

But then I need a trigger when I zoom in and out to re-write the map again (I think I do that today...)

来源:https://stackoverflow.com/questions/19124980/google-maps-markerclusterer-infobubble-selectively-display-or-hide-based-on

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!