在Google地图上隐藏其他信息窗口

时间:2015-03-11 05:04:41

标签: google-maps infowindow

我使用融合表查询突出显示了印度和墨西哥国家,我在国家印度添加了一些标记,当我用他的超链接正确点击标记弹出时。

我的问题是,当我点击地图而不是我的自定义标记时,它会弹出一个信息窗口,如下图所示。它包含有关该地点的一些信息。

演示: - Click Here

map

在这里,我想隐藏除了标记信息窗口之外的其他信息窗口,当您单击标记时,该窗口会打开。

示例代码: -

$(document).ready(function(){   

    var layer; // Fusion Tables layer

var tableid = 420419;


var image = new google.maps.MarkerImage(
                        '/static/img/icon-pin.png',
                        new google.maps.Size(68, 80),
                        new google.maps.Point(0,0),
                        new google.maps.Point(19, 49));

        var mapOptions = {
          center: new google.maps.LatLng(20.91129,-10.14098),
          zoom:3,
           el: '#map',
          disableDefaultUI: false,
          draggable: true, 
          zoomControl: true, 
          scrollwheel: true,
          icon: image,


        };

          var geocoder = new google.maps.Geocoder();
        var map = new google.maps.Map(document.getElementById("map-canvas"),
            mapOptions);



        new_boundary = new google.maps.LatLngBounds();



        var marker = new google.maps.Marker({
            map: map,
            position: new google.maps.LatLng(-25.2743980, 133.7751360),
            icon:new google.maps.MarkerImage(
            "/profiles/image/9",
            new google.maps.Size(68, 49),
            new google.maps.Point(0,0),
            new google.maps.Point(19, 49)),
            flat: true,
            anchor: 8,

          });

            new_boundary.extend(new google.maps.LatLng(-25.2743980, 133.7751360));



        var marker = new google.maps.Marker({
            map: map,
            position: new google.maps.LatLng(-40.9005570, 174.8859710),
            icon:new google.maps.MarkerImage(
            "/profiles/image/2",
            new google.maps.Size(68, 49),
            new google.maps.Point(0,0),
            new google.maps.Point(19, 49)),
            flat: true,
            anchor: 8,

          });
new_boundary.extend(new google.maps.LatLng(-40.9005570, 174.8859710));



            //map.fitBounds(new_boundary);


layer = new google.maps.FusionTablesLayer({
  query: {select: "kml_4326", 
          from: tableid,
         // where: "name_0 = 'India'"},
           where: "name_0 IN ('Mexico','India')"},

  styles: [{
  polygonOptions: {
    strokeWeight: "0",
    //strokeColor: "#FF0000",
    //strokeOpacity: "0.4",
    fillOpacity: "0.1",
    fillColor: "#FF0000"

  }
}]}); 
layer.setMap(map);
}); 

1 个答案:

答案 0 :(得分:1)

取消FusionTablesLayer上的infowindow(将suppressInfoWindows option设置为true):

layer = new google.maps.FusionTablesLayer({
  suppressInfoWindows: true,  // ** set suppressInfowindows: true
  query: {select: "kml_4326", 
          from: tableid,
           where: "name_0 IN ('Mexico','India')"},
  styles: [{
  polygonOptions: {
    strokeWeight: "0",
    fillOpacity: "0.1",
    fillColor: "#FF0000"

  }
}]}); 
layer.setMap(map);