将数据推送到用onClick事件调用的JavaScript函数

将数据推送到用onClick事件调用的JavaScript函数,javascript,jquery,google-maps,Javascript,Jquery,Google Maps,我有一个JavaScript函数,它在事件中被调用。看起来是这样的: function showArrays(event) { // Taken from Google Maps API Documentation // Since this polygon has only one path, we can call getPath() to return the // MVCArray of LatLngs. var vertices = this.getPath();

我有一个JavaScript函数,它在事件中被调用。看起来是这样的:

function showArrays(event) {
  // Taken from Google Maps API Documentation 
  // Since this polygon has only one path, we can call getPath() to return the
  // MVCArray of LatLngs.
  var vertices = this.getPath();
  var contentString = 'A';

  // Replace the info window's content and position.
  infoWindow.setContent(contentString);
  infoWindow.setPosition(event.latLng);

  infoWindow.open(map);
}
我从同一文件中先前的JavaScript函数调用此函数。我用这个代码称之为:

function initMap(){
  var myString = 'abc';
  region.addListener('click', showArrays);

  infoWindow = new google.maps.InfoWindow;
}
我还想将“myString”传递给showArrays,以便将“contentString”设置为其值。但是,我不确定如何在函数之间推送数据。我尝试编辑ShowArray以同时获取事件参数和数据参数,但这不起作用,可能是因为我的语法错误。你知道我该怎么做吗?也许用JQuery

function showArrays(event,_str) {
  // Taken from Google Maps API Documentation 
  // Since this polygon has only one path, we can call getPath() to return the
  // MVCArray of LatLngs.
  var vertices = this.getPath();
  var contentString = 'A';

  // Replace the info window's content and position.
  infoWindow.setContent(contentString+_str);
  infoWindow.setPosition(event.latLng);

  infoWindow.open(map);
}

function initMap(){
  var myString = 'abc';
  region.addListener('click', function(event){
   showArrays(event, 'myString' )
   });

  infoWindow = new google.maps.InfoWindow;
}
像这样调用回调函数,回调函数将使用对象激发ShowArray

region.addListener('click', function(event){
   showArrays(event, 'myString' )
   });

myString在哪里适合您的响应?我是如何进行检查的?我只是解释如何将参数传递到回调函数中。除了弹出窗口显示的是“myString”而不是“myString”的值之外,所有功能都正常。您的问题是如何在回调函数中传递参数,现在您说我的弹出窗口不工作。