2010-12-10 10 views
1

Der Code ist:Google Maps V3 Opazität ändern Infofenster mit jquery

function bindInfoWindow(marker, map, infoWindow, html) {       
     google.maps.event.addListener(marker, 'click', function() { 
     infoWindow.setContent("<div id='window'>" + html + "</div>"); 
    } 

und

var html = "<b>" + title + "</b> <br/><b>" + country; 

, und ich will, wenn Land Großbritannien oder USA die Opazität des #Window div zu ändern oder die infoWindow

Gibt es eine Möglichkeit, ich kann es mit jQuery tun?

thnx

Antwort

0

Sie brauchen jQuery nicht wirklich, um dies zu tun. In Ihrem CSS definiert eine Klasse mit Ihrer gewünschten Opazitätseinstellungen

.opacity { 
filter:alpha(opacity=50); //IE 

     opacity: 0.5; 

} 

ändern Sie bitte Ihre Funktion ein Land als Parameter zu übergeben und die Klasse in den div auf dem gewünschten Wert

function bindInfoWindow(marker, map, infoWindow, html, country) {       
      google.maps.event.addListener(marker, 'click', function() { 
    opacityClass = (country=="UK" || country == "US") ? "opacity" : ""; 

infoWindow.setContent("<div id='window' class="+opacityClass+">" + html + "</div>"); 
     } 

oder wenn Sie je hinzufügen möchte jquery verwenden

 function bindInfoWindow(marker, map, infoWindow, html, country) {       
       google.maps.event.addListener(marker, 'click', function() { 
     if (country=="UK" || country == "US") { 
$("#window").addClass("opacity") 
} 

    infoWindow.setContent("<div id='window'>" + html + "</div>"); 
      }