2012-04-15 8 views
12

Ho un'immagine che voglio aggiungere a un marker, stagleton.png, e ho una funzione per creare un marker. Come cambio il metodo InfoWindow in modo che l'immagine venga visualizzata anche con il testo in InfoWindow?Come aggiungere un'immagine a InfoWindow dell'indicatore in google maps v3?

function createMarker(name, latlng, mapsent) 
{ 
    var marker = new google.maps.Marker({ 
         position: latlng, 
         map: mapsent, 
         title: name 
         }); 
    marker.info = new google.maps.InfoWindow({ 
       //when I add <IMG BORDER="0" ALIGN="Left" SRC="stagleton.jpg"> the maps will not load 
     content: <IMG BORDER="0" ALIGN="Left" SRC="stagleton.jpg"> "My name is " + name 

    }); 

    google.maps.event.addListener(marker, 'click', function(){ 
     marker.info.open(mapsent, marker); 
    }); 
    return marker; 
} 

risposta

24

Prova:

content: '<IMG BORDER="0" ALIGN="Left" SRC="stagleton.jpg"> My name is ' + name 
3

@ Dr.Molle, hai provato che in IE? Non riesco ad aprire le finestre di informazioni in IE ogni volta che hanno un'immagine al loro interno. Sono solo piccoli con la X per chiuderla, ma nessun altro contenuto.

Non appena rimuovo l'immagine, il resto del contenuto (tag h1, collegamenti, testo) si visualizza bene e si apre la finestra di informazioni.

Eventuali indizi ??


EDIT: E 'necessario specificare attributi altezza e larghezza nel tag IMG per IE per essere in grado di rendere l'infowindow con un'immagine in esso. IE è il browser peggiore della storia, che POS ...

Speriamo che questo aiuti qualcuno!

0
var contentString = "<a href=/popups/" + id + '>' + name + "</a>" + '<br>' + address 
    + '<br>' + category + '<br>' + "<img width='80' src=" + image + ">" ; 

Questo ha funzionato per me.

+0

Controlla la mia risposta, hai eseguito il test in IE? – SeanKendle

Problemi correlati