Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Google Maps Infowindow Close Icon

How can I change the default graphic for the Infowindow close button?

like image 278
David Avatar asked Oct 23 '09 16:10

David


People also ask

How do I add buttons to InfoWindow?

addListener(marker, 'click', function() { infowindow. setContent('<p>Event Name: '+this. title+'</p>' + '<p>Event Type: '+this. etype+'</p>' + '<p>Cause: '+this.

How do I change the background color of InfoWindow in Google Maps?

addListener(marker, 'mouseover', function() { infoWindow. setContent(html); infoWindow. open(map, marker); //infoWindow. setStyle("background-color: red"); });


1 Answers

First you need to hide the default close icon:

.gm-style-iw button.gm-ui-hover-effect img {
    display: none !important;
}

Second, force the default button (that holds the image) to have full opacity:

.gm-style-iw button.gm-ui-hover-effect {
  opacity: 1 !important;
}

Third, set your own image and position it:

.gm-style-iw button.gm-ui-hover-effect:before {
  display: block;
  content: "";
  background: url('assets/close-red.svg') center center no-repeat;
  background-size: cover;
  width: 8px;
  height: 8px;
  right: -19px;
  position: relative;
}

Result:

custom-close-button

like image 183
Grant Avatar answered Sep 25 '22 21:09

Grant