2016-05-10 8 views
3

Ich möchte schließen Schaltfläche aus InfoBox-Fenster in Google Map API, aber ich habe keine Ahnung, wie dies zu tun ist.Wie ausgeblendet schließen (x) Schaltfläche aus InfoBox-Fenster in Google Map API 3?

CSS-Code:

#infobox { 
    padding: 0 0 8px 0; 
    margin: -95px 0 0 -15px; 
    min-width: 180px; 
    margin-top: 8px; 
    color: rgb(94, 94, 94); 
    font-family: Gotham SSm A,Gotham SSm B,Halvetica,sans-serif; 
    font-size: 12px; 
    z-index: 1000; 
    transition: box-shadow .25s; 
    padding: 1px; 
    font-size: 12px; 
    background-color: #ce93d8; 
    -webkit-border-radius: 2px; 
    -moz-border-radius: 2px; 
    border-radius: 2px; 
    -webkit-box-shadow: 0 0 8px #9c27b0; 
    box-shadow: 0 0 8px #9c27b0; 
} 

JavaScript-Code:

infobox = new InfoBox({ 
    disableAutoPan: false, 
    maxWidth: 150, 
    pixelOffset: new google.maps.Size(-140, 0), 
    zIndex: null, 
    boxStyle: { 
       background: "url('http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/examples/tipbox.gif') no-repeat", 
       width: "150px" 
     }, 
    closeBoxMargin: "12px 4px 2px 2px", 
    closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif", //close button icon 
    infoBoxClearance: new google.maps.Size(1, 1) 
}); 
+0

können Sie es auf Codepen einfügen? – 1N5818

Antwort

4

Stellen Sie einfach closeBoxUrl zu "". Nach dem docs:

"closeBoxURL. Die URL des Bildes in das Schließfeld darstellt. Hinweis: Der Standardwert ist die URL für Standard Google Box schließen Setzen Sie diese Eigenschaft auf "" wenn keine enge Box erforderlich ist . "

Sie müssen nur eine Zeile ändern: closeBoxURL: "".

infobox = new InfoBox({ 
      disableAutoPan: false, 
      maxWidth: 150, 
      pixelOffset: new google.maps.Size(-140, 0), 
      zIndex: null, 
      boxStyle: { 
         background: "url('http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/examples/tipbox.gif') no-repeat", 
         width: "150px" 
       }, 
      closeBoxMargin: "12px 4px 2px 2px", 
      closeBoxURL: "", //THE CHANGE 
      infoBoxClearance: new google.maps.Size(1, 1) 
     }); 
0

JQuery:

$(".gm-style-iw").next("div").hide(); 

Event-Handler:

google.maps.event.addListener(infowindow, 'domready', function(){ 
    $(".gm-style-iw").next("div").hide(); 
}); 

CSS:

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

Ein weiteres Ereignis-Handler:

So Ihre vollständigen Code würde wie folgt aussehen
$(".gm-style-iw:contains(" + infoText + ")").css("left", function() { 
    return ($(this).parent().width() - $(this).width())/2; 
}).next("div").remove(); 

Wählen Sie, welches überhaupt für Sie am besten funktioniert! Viel Glück!

+2

Was für eine schlechte Antwort ... – MrUpsidown