Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 谷歌地图点击外部链接标记_Jquery_Html_Google Maps_Geolocation_Marker - Fatal编程技术网

Jquery 谷歌地图点击外部链接标记

Jquery 谷歌地图点击外部链接标记,jquery,html,google-maps,geolocation,marker,Jquery,Html,Google Maps,Geolocation,Marker,谷歌地图,点击外部链接目标标记。找到下面的小提琴演示 google.maps.event.addListener(marker, 'click', (function(marker, i) { return function() { infowindow.setContent(locations[i][0]); infowindow.open(map, marker); map.setZoom(9);

谷歌地图,点击外部链接目标标记。找到下面的小提琴演示

google.maps.event.addListener(marker, 'click', (function(marker, i) {

        return function() {
          infowindow.setContent(locations[i][0]);
          infowindow.open(map, marker);
          map.setZoom(9);
          map.setCenter(marker.getPosition());  
        }
      })(marker, i));

function triggerClick(i) {
    google.maps.event.trigger(markers[i],'click');
}

<ul class="nav">
<li><a href="javascript:triggerClick(0)">location1</a></li>
<li><a href="javascript:triggerClick(1)">location2</a></li>
<li><a href="javascript:triggerClick(2)">location3</a></li>
<li><a href="javascript:triggerClick(3)">location4</a></li>
</ul>
google.maps.event.addListener(标记,'click',(函数(标记,i){
返回函数(){
infowindow.setContent(位置[i][0]);
信息窗口。打开(地图、标记);
map.setZoom(9);
map.setCenter(marker.getPosition());
}
})(marker,i));
功能触发点击(一){
google.maps.event.trigger(标记[i],'click');
}

我得到javascript错误:
未捕获引用错误:triggerClick未在您的小提琴中定义。
triggerClick
函数是onLoad函数的本地函数,它需要是全局函数才能在HTML单击函数中使用

代码段:

var markers=new Array();
var映射;
变量位置=[
[“新德里国际艺术节”,28.61393977.209021],
['ICCR-地平线系列,新德里',28.625439,77.245715],
[Shree Arobindo Asharam,Pondecherry',11.936761,79.834314],
[With Shuba Mudgal,Florance,Italy',43.769560,11.255814],
[《英国伦敦S.A.I.D.古典钢琴》,51.507351,-0.127758],
[“美国和加拿大纳尔坦学院的钢琴未插电”,40.712784,-74.005941]
];
//设置不同的图标和阴影
变量iconURLPrefix=http://maps.google.com/mapfiles/ms/icons/';
变量图标=[
iconURLPrefix+“red dot.png”,
iconURLPrefix+“green dot.png”,
iconURLPrefix+“green dot.png”,
iconURLPrefix+“red dot.png”,
iconURLPrefix+“purple dot.png”,
iconURLPrefix+“green dot.png”
]
var iconsLength=icons.length;
函数初始化(){
map=new google.maps.map(document.getElementById('map'){
缩放:10,
中心:新google.maps.LatLng(20.59,78.96),
mapTypeId:google.maps.mapTypeId.ROADMAP,
mapTypeControl:false,
街景控制:错误,
泛控制:错误,
ZoomControl选项:{
位置:google.maps.ControlPosition.LEFT_底部
}
});
var infowindow=new google.maps.infowindow({
最大宽度:160
});
var-iconCounter=0;
//将标记和信息窗口添加到地图
对于(变量i=0;i=iconsLength){
i计数器=0;
}
}
自动中心();
}
google.maps.event.addDomListener(窗口“加载”,初始化);
功能触发点击(一){
google.maps.event.trigger(标记[i],'click');
//map.getBounds();
}
函数autoCenter(){
//创建新的视点边界
var bounds=new google.maps.LatLngBounds();
//通过每个。。。
对于(var i=0;i
正文{
填充:0;
保证金:0;
}
.集装箱{
宽度:100%;
身高:100%;
}
.档案地图{
宽度:100%;
高度:400px;
}
.导航{
背景:rgba(0,0,0,0.5);
宽度:100%;
文本对齐:居中;
保证金:0;
左侧填充:0;
}
李国荣先生{
显示:内联块;
}
李娜先生{
颜色:#fff;
填充:10px;
显示:块;
位置:相对位置;
z指数:100;
}