2012-07-03 6 views
0

Je suis confronté à un énorme problème pour résoudre la taille de la fenêtre d'information. Je veux montrer un bloc d'image et quelques informations de texte dans la fenêtre d'information mais après avoir placé la taille de la fenêtre d'information de contenu augmentée j'ai lu quelques discussions mais aucune chance avec mon code. Quelqu'un peut-il m'aider à le régler.Redimensionner la fenêtre d'information de google map V3

// Creating an object literal containing the properties 
// we want to pass to the map 
var options = { 
    zoom: 5, 
    center: new google.maps.LatLng(44.913990, 15.205078), 
    mapTypeId: google.maps.MapTypeId.ROADMAP , 
    }; 
// Creating the map 
var map = new google.maps.Map(document.getElementById("map"), options); 
// Creating a LatLngBounds object 
var bounds = new google.maps.LatLngBounds(); 
// Creating an array that will contain the coordinates 
// for New York, San Francisco, and Seattle 
    var content = []; 
    var places = [];content.push('Some html'); 
    places.push(new google.maps.LatLng(44.913990, 15.205078)); 
// Creating a variable that will hold 
// the InfoWindow object 
var infowindow; 

// Looping through the places array 
for (var i = 0; i < places.length; i++) 
{ 
    // Adding the markers 
    var marker = new google.maps.Marker({ 
    position: places[i], 
    map: map, 
    icon: "/themes/garland/images/beach_icon_gmap.png" 
    // title: "Place number " + i 
    }); 

    // Wrapping the event listener inside an anonymous function 
    // that we immediately invoke and passes the variable i to. 
    (function(i, marker) { 
    // Creating the event listener. It now has access to the values of 
    // i and marker as they were during its creation 
    google.maps.event.addListener(marker, "click", function() { 

     // Check to see if we already have an InfoWindow 
     if (!infowindow) { 
     infowindow = new google.maps.InfoWindow({ 
      maxWidth: 20, 
      maxheight: 20 
     }); 
     } 

     // Setting the content of the InfoWindow 
     infowindow.setContent(content[i]); 

     // Tying the InfoWindow to the marker 
     infowindow.open(map, marker); 

    }); 

    })(i, marker); 

    // Extending the bounds object with each LatLng 
    bounds.extend(places[i]); 
} 
// Adjusting the map to new bounding box 
// map.fitBounds(bounds) 

Toute aide serait grandement appréciée. Merci d'avance.

Répondre

0

La première chose que je remarque dans votre code: maxWidth est une propriété valide de l'objet InfoWindowOptionsapi-doc qui est passé au constructeur InfoWindow, mais maxheight n'est pas. Vous ne serez pas en mesure de traiter le InfoWindow comme un conteneur strict ou rigide, bien que maxWidth limitera la largeur. Un InfoWindow est toujours dimensionné pour contenir le contenu qui lui a été fourni. À partir de l'API Doc:

L'info-fenêtre sera dimensionnée en fonction du contenu. Pour définir une taille explicite pour le contenu, définissez le contenu à être un élément HTML avec cette taille.

Cela dit, vous êtes en mesure de contrôler la taille, l'affichage, la couleur, etc. d'un InfoWindow en définissant une classe CSS et l'application des règles de style au contenu de la fenêtre. Adopter l'approche CSS pour le contenu vous donnera un contrôle complet sur la taille du contenu, car le InfoWindow fonctionne simplement comme un conteneur pour le contenu. Si une règle CSS aboutit à un contenu de la taille correcte, votre taille InfoWindow aura la taille correcte.