2010-09-06 7 views

Répondre

2

Depuis que vous utilisez le v3 API vous pouvez simplement empêcher le infoWindow de déplacer la carte avec l'option disableAutoPan.

Exemple complet:

<!DOCTYPE html> 
<html> 
<head> 
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
    <title>Google Maps disableAutoPan Demo</title> 
    <script src="http://maps.google.com/maps/api/js?sensor=false" 
      type="text/javascript"></script> 
</head> 
<body> 

    <div id="map" style="width: 200px; height: 200px"></div> 

    <script type="text/javascript"> 

    var myLatlng = new google.maps.LatLng(37.44, -122.14); 
    var myOptions = { 
     zoom: 4, 
     center: myLatlng, 
     mapTypeId: google.maps.MapTypeId.ROADMAP 
    } 

    var map = new google.maps.Map(document.getElementById("map"), myOptions); 

    var infowindow = new google.maps.InfoWindow({ 
     content: 'Test', 
     disableAutoPan: true 
    }); 

    var marker = new google.maps.Marker({ 
     position: myLatlng, 
     map: map, 
     title: 'Test Marker' 
    }); 

    google.maps.event.addListener(marker, 'click', function() { 
    infowindow.open(map, marker); 
    }); 

    </script> 
</body> 
</html> 

Screenshot:

disableAutoPan

Il n'y a pas d'équivalent à la disableAutoPan dans le v2 API'sGInfoWindowOptions, et je ne suis pas au courant des solutions de contournement pour cela.

+0

Merci.C'est une bonne solution de contournement.La fenêtre d'information redimensionne également (il va plus petit) donc je pense que je fais quelques erreurs ici.Il travaillait il y a 2 jours ... –

Questions connexes