Jquery 谷歌地图信息容器问题
关于我的谷歌地图集成,我有两个顾虑 一,。信息容器的显示方式如下 2.让它成为我点击的三个指针中的任何一个,信息容器显示在同一个位置 我如何解决这个问题 这是我的密码Jquery 谷歌地图信息容器问题,jquery,google-maps,Jquery,Google Maps,关于我的谷歌地图集成,我有两个顾虑 一,。信息容器的显示方式如下 2.让它成为我点击的三个指针中的任何一个,信息容器显示在同一个位置 我如何解决这个问题 这是我的密码 for(var gMarker = 0; gMarker < userData.records.length ; gMarker++){ var gMarkerThisImage = userData.records[gMarker].LatLng; var marker = new
for(var gMarker = 0; gMarker < userData.records.length ; gMarker++){
var gMarkerThisImage = userData.records[gMarker].LatLng;
var marker = new google.maps.Marker({
position: new google.maps.LatLng(gMarkerThisImage[0], gMarkerThisImage[1]),
map: map,
title: 'U.S.A center'
});
(function(Marker) {
console.log(gMarkerThisImage[0], gMarkerThisImage[1]);
var contentString = '<div id="imageContent">'+
'<img src="'+userData.records[gMarker].imagePath+'" width = "100" height="100" alt = >'+
'</div>';
var infowindow = new google.maps.InfoWindow({
content: contentString ,
position : new google.maps.LatLng(gMarkerThisImage[0], gMarkerThisImage[1])
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
/*google.maps.event.addListener(marker, 'mouseout', function() {
infowindow.close(map,marker);
});*/
}(marker));
}
for(var-gMarker=0;gMarker
我已经重新组织了您的代码,请看一看-
var infowindow = new google.maps.InfoWindow(); //declare it globally if you want one infowindow at a time.
for(var gMarker = 0; gMarker < userData.records.length ; gMarker++){
var gMarkerThisImage = userData.records[gMarker].LatLng;
var marker = new google.maps.Marker({
position: new google.maps.LatLng(gMarkerThisImage[0], gMarkerThisImage[1]),
map: map,
title: 'U.S.A center'
});
(function(Marker) {
console.log(gMarkerThisImage[0], gMarkerThisImage[1]);
var contentString = '<div id="imageContent">'+
'<img src="'+userData.records[gMarker].imagePath+'" width = "100" height="100" alt = >'+
'</div>';
myWindow(marker,contentstring);
});
}(marker));
}
function myWindow(mark, content)
{
google.maps.event.addListener(mark, 'mouseover', function() {
infowindow.open(map,mark);
infowindow.setContent(content);
});
}
var infowindow=new google.maps.infowindow()//如果一次只需要一个infowindow,请全局声明它。
对于(var-gMarker=0;gMarker
您的第一个问题与css相关。我怀疑这是因为图像尺寸太大,并且锚点(箭头)渲染不正确。用一个小图像进行测试,然后查看。