google maps v3 marker info window on mouseover

前端 未结 3 1055
执念已碎
执念已碎 2020-12-13 01:34

I have scoured stackoverflow and other forums including the google maps v3 api docs for an answer but I cannot find how to change the event that fires the marker info window

相关标签:
3条回答
  • 2020-12-13 02:12

    Thanks to duncan answer, I end up with this:

    marker.addListener('mouseover', () => infoWindow.open(map, marker))
    marker.addListener('mouseout', () => infoWindow.close())
    
    0 讨论(0)
  • 2020-12-13 02:19

    Here's an example: http://duncan99.wordpress.com/2011/10/08/google-maps-api-infowindows/

    marker.addListener('mouseover', function() {
        infowindow.open(map, this);
    });
    
    // assuming you also want to hide the infowindow when user mouses-out
    marker.addListener('mouseout', function() {
        infowindow.close();
    });
    
    0 讨论(0)
  • 2020-12-13 02:25
    var icon1 = "imageA.png";
    var icon2 = "imageB.png";
    
    var marker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        icon: icon1,
        title: "some marker"
    });
    
    google.maps.event.addListener(marker, 'mouseover', function() {
        marker.setIcon(icon2);
    });
    google.maps.event.addListener(marker, 'mouseout', function() {
        marker.setIcon(icon1);
    });
    
    0 讨论(0)
提交回复
热议问题