google map API v3 change marker icon on click?

前端 未结 3 1041
误落风尘
误落风尘 2021-02-07 08:02

Following google documentation up to changing the marker icon was easy. But I\'m stuck, I don\'t know how to change image when marker is clicked?

My code so far:

3条回答
  •  孤街浪徒
    2021-02-07 08:39

    Try this.

    //open onclick
       google.maps.event.addListener(marker, 'click', function() {
        marker.setIcon("Your Image");                                    
        infowindow.open(map);
        });
    

提交回复
热议问题