admin管理员组

文章数量:1410688

I just looked at the following post: markerclusterer info windows

There's a thing I need in this post, the mouseover event for the markerclusterer. I need to change the icon when the mouse is hovered over the icon.

I got the following code:

var clusterOptions = {
    zoomOnClick: false,
    styles: [{
        url: 'images/template/cluster.png',
        height: 68, 
        width: 57,
        textColor: '#FFF'
    }]
}
var markerClusterer = new MarkerClusterer(map, markers, clusterOptions);

google.maps.event.addListener(markerClusterer, "mouseover", function(cluster) {
    console.log('test');
});

// Listen for a cluster to be clicked
google.maps.event.addListener(markerClusterer, 'clusterclick', function(cluster) {

    var markers = cluster.getMarkers();
    var content = '';
    $.each(markers, function () {
        content += this.get('content');
    });

    // Convert lat/long from cluster object to a usable MVCObject
    var info = new google.maps.MVCObject;
    info.set('position', cluster.center_);

    var infowindow = new google.maps.InfoWindow();
    infowindow.close();
    infowindow.setContent(content);
    infowindow.open(map, info);

});

The clusterer works fine and also the infowindow shows up nice. It bines all the infowindows from the markers in the cluster.

What am I doing wrong in the mouseover event? I don't even see the console.log!

Thanks in advance

I just looked at the following post: markerclusterer info windows

There's a thing I need in this post, the mouseover event for the markerclusterer. I need to change the icon when the mouse is hovered over the icon.

I got the following code:

var clusterOptions = {
    zoomOnClick: false,
    styles: [{
        url: 'images/template/cluster.png',
        height: 68, 
        width: 57,
        textColor: '#FFF'
    }]
}
var markerClusterer = new MarkerClusterer(map, markers, clusterOptions);

google.maps.event.addListener(markerClusterer, "mouseover", function(cluster) {
    console.log('test');
});

// Listen for a cluster to be clicked
google.maps.event.addListener(markerClusterer, 'clusterclick', function(cluster) {

    var markers = cluster.getMarkers();
    var content = '';
    $.each(markers, function () {
        content += this.get('content');
    });

    // Convert lat/long from cluster object to a usable MVCObject
    var info = new google.maps.MVCObject;
    info.set('position', cluster.center_);

    var infowindow = new google.maps.InfoWindow();
    infowindow.close();
    infowindow.setContent(content);
    infowindow.open(map, info);

});

The clusterer works fine and also the infowindow shows up nice. It bines all the infowindows from the markers in the cluster.

What am I doing wrong in the mouseover event? I don't even see the console.log!

Thanks in advance

Share Improve this question edited May 23, 2017 at 11:46 CommunityBot 11 silver badge asked May 15, 2012 at 9:39 Jacob FranckeJacob Francke 4656 silver badges24 bronze badges 2
  • Hi, I just resolved the issue, i'll post the answer when I can, but have to wait because I don't have enough reputationpoints to answer it straight away :) – Jacob Francke Commented May 15, 2012 at 11:58
  • can you tell something more now? – ricricucit Commented Jul 28, 2012 at 14:08
Add a ment  | 

2 Answers 2

Reset to default 4

My solution was using markerclustererplus rather than markerclusterer. Just replace your script src. Here is an example.

You should use the following library:

https://github./googlemaps/v3-utility-library/tree/master/markerclustererplus

it has mouseover handlers http://htmlpreview.github.io/?https://github./googlemaps/v3-utility-library/blob/master/markerclustererplus/docs/reference.html

本文标签: javascriptmarkerclusterer mouseover doesn39t workStack Overflow