Javascript 谷歌地图API格式的电话号码在侧栏的列表中显示为未定义

Javascript 谷歌地图API格式的电话号码在侧栏的列表中显示为未定义,javascript,google-maps-api-3,Javascript,Google Maps Api 3,我正试图在骑乘侧栏上显示一个地点列表及其电话号码。当我点击标记时,电话号码起作用,但在侧栏中显示为未定义。任何帮助都很好,谢谢 $(document).ready(function(){ var map = null; var gmarkers = []; var service = null; var infowindow = new google.maps.InfoWindow({size: new google.maps.Size(150,50)

我正试图在骑乘侧栏上显示一个地点列表及其电话号码。当我点击标记时,电话号码起作用,但在侧栏中显示为未定义。任何帮助都很好,谢谢

   $(document).ready(function(){  

    var map = null;
    var gmarkers = [];
    var service = null;
    var infowindow = new google.maps.InfoWindow({size: new google.maps.Size(150,50)});

  function initialize() {
    var slo = new google.maps.LatLng(35.2742, -120.6631);

    map = new google.maps.Map(document.getElementById('map'), {
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      center: slo,
      zoom: 11
    });

    service = new google.maps.places.PlacesService(map);

    var request = {
      location: slo,
      radius: 30000,
      types: ['hospital']
    };
    infowindow = new google.maps.InfoWindow();
    service.nearbySearch(request, callback);
  }

  function callback(results, status) {
    if (status == google.maps.places.PlacesServiceStatus.OK) {
      for (var i = 0; i < results.length; i++) {
        createMarker(results[i]);
      }
    }
  }

  function createMarker(place) {
    var placeLoc = place.geometry.location;
if (place.icon) {
  var image = new google.maps.MarkerImage(
            place.icon, new google.maps.Size(71, 71),
            new google.maps.Point(0, 0), new google.maps.Point(17, 34),
            new google.maps.Size(25, 25));
 } else var image = null;

    var marker = new google.maps.Marker({
      map: map,
      icon: image,
      position: place.geometry.location
    });
var request =  {
      reference: place.reference
};

google.maps.event.addListener(marker,'click',function(){
    service.getDetails(request, function(place, status) {
      if (status == google.maps.places.PlacesServiceStatus.OK) {
        var contentStr = '<h5>'+place.name+'</h5><p>'+place.formatted_address;
        if (!!place.formatted_phone_number) contentStr += '<br>'+place.formatted_phone_number;
        if (!!place.website) contentStr += '<br><a target="_blank" href="'+place.website+'">'+place.website+'</a>';
        contentStr += '<br>'+place.types+'</p>';
        infowindow.setContent(contentStr);
        infowindow.open(map,marker);
      } else { 
        var contentStr = "<h5>No Result, status="+status+"</h5>";
        infowindow.setContent(contentStr);
        infowindow.open(map,marker);
      }
    });

});
gmarkers.push(marker);
 var side_bar_html = "<a href='javascript:google.maps.event.trigger(gmarkers["+parseInt(gmarkers.length-1)+"],\"click\");'>"+place.name+"-"+place.formatted_phone_number+"</a><br>";
 document.getElementById('side_bar').innerHTML += side_bar_html;
    }

  google.maps.event.addDomListener(window, 'load', initialize);



    });
$(文档).ready(函数(){
var-map=null;
var gmarkers=[];
var服务=null;
var infowindow=new google.maps.infowindow({size:new google.maps.size(150,50)});
函数初始化(){
var slo=new google.maps.LatLng(35.2742,-120.6631);
map=new google.maps.map(document.getElementById('map'){
mapTypeId:google.maps.mapTypeId.ROADMAP,
中心:slo,,
缩放:11
});
服务=新的google.maps.places.PlacesService(地图);
var请求={
地点:slo,
半径:30000,
类型:[“医院”]
};
infowindow=new google.maps.infowindow();
服务.nearbySearch(请求、回调);
}
函数回调(结果、状态){
if(status==google.maps.places.PlacesServiceStatus.OK){
对于(var i=0;i';
infowindow.setContent(contentStr);
信息窗口。打开(地图、标记);
}否则{
var contentStr=“无结果,状态=“+status+”;
infowindow.setContent(contentStr);
信息窗口。打开(地图、标记);
}
});
});
G标记器。推(标记器);
var side_bar_html=“
”; document.getElementById('side\u bar')。innerHTML+=side\u bar\u html; } google.maps.event.addDomListener(窗口“加载”,初始化); });
信息窗口中显示的格式化电话号码将在中返回,单击标记时会发生这种情况,但在中不可用,该标记用于创建侧边栏