JQuery地图用户界面和从链接打开信息窗口

JQuery地图用户界面和从链接打开信息窗口,jquery,google-maps,map,Jquery,Google Maps,Map,如前所述,我正在使用JQuery Map UI插件,我很难找到一个位置列表,一旦单击,就会打开地图中的信息窗口 这是我的工作代码,用于拉入地图标记并输出地图外的位置列表 $.getJSON( 'data.php', function(data) { $.each( data.markers, function(i, m) { var temp = m.services.split(','); $('#map_canvas').gmap('addMarker', {

如前所述,我正在使用JQuery Map UI插件,我很难找到一个位置列表,一旦单击,就会打开地图中的信息窗口

这是我的工作代码,用于拉入地图标记并输出地图外的位置列表

$.getJSON( 'data.php', function(data) {
$.each( data.markers, function(i, m) {
    var temp = m.services.split(',');
    $('#map_canvas').gmap('addMarker', {
        'position': new google.maps.LatLng(m.lat, m.lng),
        'bounds': true,
        'services':temp
    }).click(function() {
       $('#map_canvas').gmap('openInfoWindow', { 'content': m.address }, this);
    });
   //list of locations that once click, will open the map info window
    $('ul.list').append('<li><a href="#" >' + m.address + '</a></li>');
});
});
$.getJSON('data.php',函数(数据){
$.each(data.markers,function(i,m){
var temp=m.services.split(',');
$('map#u canvas').gmap('addMarker'{
“位置”:新的google.maps.LatLng(m.lat,m.lng),
“界限”:对,
“服务”:临时
})。单击(函数(){
$('map_canvas').gmap('openInfoWindow',{'content':m.address},this);
});
//单击后将打开“地图信息”窗口的位置列表
$('ul.list')。追加('li>');
});
});
从现在起,上面只允许地图内的实际标记打开信息窗口。如果您有任何关于UL项目列表可点击并打开信息窗口的帮助/指导,我们将不胜感激。

I可能的方式(可能还有其他方式):

google.maps.Marker
-实例存储为
  • -元素的属性,因此您可以单击此元素访问它并触发单击标记:

    $.each( data.markers, function(i, m) {
        var temp = m.services.split(',');
    
        var marker=//<--create a local variable
              $('#map_canvas').gmap('addMarker', {
                'position': new google.maps.LatLng(m.lat, m.lng),
                'bounds': true,
                'services':temp
                }).click(function() {
                    $('#map_canvas').gmap('openInfoWindow', { 'content': m.address }, this);
            })[0];//<--note the [0]
    
       //list of locations that once click, will open the map info window
        $('<li><a href="#" >' + m.address + '</a></li>')
          .data('marker',marker)
           .appendTo('ul.list')
            .click(function(e){
                    e.preventDefault();
                    google.maps.event.trigger($(this).data('marker'),'click');
                  });
    });
    
    $。每个(数据标记、函数(i、m){
    var temp=m.services.split(',');
    
    var marker=//现场直播。非常感谢!