JavaScript函数仅在第一次执行

时间:2016-05-03 16:57:34

标签: javascript function infowindow

我有这个功能,它第一次工作正常,但是当我第二次尝试执行它时它不起作用,为什么会这样?

$("#miBoton").on('click', function() {
  var text = $("#myText").val();
  map.data.forEach(function(feature) {
    if (text == feature.getProperty('SECTION')) {
      map.data.revertStyle();
      map.data.overrideStyle(feature, {
        strokeWeight: 8
      });
      var x = feature.getProperty("CX");
      var y = feature.getProperty("CY");
      var center = {
        lat: y,
        lng: x
      };
      infoWindow = new google.maps.InfoWindow({
        position: center
      });
      var contentString = '<div class="infoSection">' +
        '<div  class="iwTittle">' +
        '<h3 style="margin-top:0px!important; margin-bottom:0px!important; padding:0px;"> Seccion :' + feature.getProperty('SECTION') + '</h3>' +
        '</div>' +

        '<div id="bodyContent">' +
        '<h4> Distrito :' + feature.getProperty('DLOCAL') + '</h4>' +
        '<iframe src="../window.php?section=' + feature.getProperty('SECTION') + '" style="width:100%; height:350px; border:0px"></iframe>'
      '</div>' +
      '</div>';
      infoWindow.setContent(contentString);
      infoWindow.open(map);
    }
  });
  var text = null;
});

0 个答案:

没有答案