如何使用API​​(V3)在Google地图中禁用弹出气球

时间:2011-07-25 15:07:03

标签: google-maps map google-maps-api-3

我正在使用Google Maps API V3(因此没有嵌入链接),我希望当用户点击我的多边形(叠加层)时,他们看不到白色弹出气球。

气球的内容(以及坐标)来自KML文件。

以下是我用于生成地图的内容。

  <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
  <script type="text/javascript">
  function initialize() {
  var paris = new google.maps.LatLng(48.8581,2.3827 );
  var myOptions = {
  zoom: 4,
  center: paris,
  mapTypeId: google.maps.MapTypeId.ROADMAP
 }

 var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
 var france = new google.maps.KmlLayer('france.kml?v=45', {preserveViewport:true});
 var germany = new google.maps.KmlLayer('germany.kml?v=45', {preserveViewport:true});

 france.setMap(map);  
 germany.setMap(map);
  }
</script>

1 个答案:

答案 0 :(得分:2)

将加载KML的变量更改为如下所示:

var kmlLayer;

var kmlURL = 'http://www.yourwebsite.com/mapFileName.kml';
    var kmlOptions = {
        clickable: 0, // polygon ignores mouse clicks
        preserveViewport: 1
    };
kmlLayer = new google.maps.KmlLayer(kmlURL, kmlOptions);
kmlLayer.setMap(map);