15

How to remove close icon of info window in google map. I tried to remove this icon, but couldn't find id or class for that.

So can anyone help me to remove close icon from info window?

Alexey Zalyotov
  • 326
  • 2
  • 5
  • 16
Visva
  • 194
  • 1
  • 3
  • 11

10 Answers10

35

You can hide close button with CSS:

.gm-style-iw + div {display: none;}
J0e3gan
  • 8,740
  • 10
  • 53
  • 80
Eugene Godun
  • 376
  • 3
  • 5
18

This worked for me with just css

.gm-ui-hover-effect {
    display: none !important;
}
hassanrazadev
  • 626
  • 9
  • 15
2

I tried all suggestions above, but failed. I tried using jquery $('.gm-style-iw').next().hide(), it did not work as well.

This is what worked for me, in case someone needs it. This is what I did with GMAP API V3.

.gm-style .gm-style-iw + div {
    display: none; /* <-- this will generally work on the fly. */
    visibility: hidden; /* this 2 lines below are just for hard hiding. :) */
    opacity: 0;
}

Generally, what it does is, it looks for direct sibling of that gm-style-iw which is created dynamically by the API. The div right next to the gm-style-iw is the close button.

Hope that helps. :)

Unheilig
  • 16,196
  • 193
  • 68
  • 98
Jovanni G
  • 322
  • 1
  • 7
  • 17
2
button.gm-ui-hover-effect {
    visibility: hidden;
}

That works as at today in Chrome and Edge

Adrita Sharma
  • 21,581
  • 10
  • 69
  • 79
PeeBee
  • 21
  • 1
1

You can try this

::ng-deep .gm-style .gm-style-iw-c button {
    display: none !important;
}

The magic inside it is ::ng-deep modifier that can search deeply for the styles and override them.

0

For people using Google Maps API v2, this function will open an info window with no close icon:

openInfoWindowHtml(html, {
  maxWidth: 200, buttons: { close: { visible: false } }
});
Preview
  • 35,317
  • 10
  • 92
  • 112
Shahe
  • 964
  • 2
  • 13
  • 34
  • where do i insert in my code. my sample code `marker.setMap(map); $('body').append('
    ') $("#targetdiv").load('ProgressBar1.jsp'); var innerhtml=document.getElementById("targetdiv"); var infowindow = new google.maps.InfoWindow({ content: innerhtml, maxWidth:200, buttons:{close:{visible: false}}, }); infowindow.open(map,marker); //openInfoWindowHtml(document.getElementById("targetdiv"), {maxWidth:200, buttons:{close:{visible: false}}}); marker.setMap(map);`
    – Visva Dec 12 '13 at 13:56
  • You are already have the code: `buttons:{close:{visible:false}}`. It should work, what browser are you using? – Shahe Dec 13 '13 at 06:45
  • i am using mozilla firefox 24.0 – Visva Dec 16 '13 at 04:53
  • 4
    This answer is dated. It applies to Google Maps API 2, which Google no longer supports. The new API doesn't have an openInfoWindowHtml function. – Michael Scheper Jul 22 '14 at 04:28
0

I did it setting closeBoxURL to an empty string on the options object

infoboxOptions = {

    closeBoxURL: '',
    ...

}

var infobox = new InfoBox(infoboxOptions);
Agu Dondo
  • 12,638
  • 7
  • 57
  • 68
0

You can try this

.gm-style-iw + div{ display: none; } // hide div

.gm-style-iw + div + img{ display: none; } // hide img 
Rob
  • 26,989
  • 16
  • 82
  • 98
0
.gm-style-iw button>img {
    display: none!important;
}

This code piece will make it to work. In my case image representing the close button was inside button tag in div classed gm-style-iw

Roman T.
  • 333
  • 3
  • 10
0

Add this in your CSS:

button.gm-ui-hover-effect {
   visibility: hidden;
}

This worked perfectly with Maps API v3.43

Saurabh R S
  • 3,037
  • 1
  • 34
  • 44