【发布时间】:2026-02-13 20:00:02
【问题描述】:
我正在尝试将 Google 地图中的信息窗口更改为智能信息窗口,但由于某种原因,信息窗口的位置错误。标准信息窗口我从来没有遇到过这个问题,只有智能信息窗口。
我发现,如果我使用 Firefox 检查器删除 position: relative,地图将移动到窗口的左上角,然后 smartinfowindows 处于正确的位置。
那么我有什么遗漏吗?
我使用以下内容创建标记:
for (var i = 0; i < data.locations.length; i++) {
var dataPhoto = data.locations[i];
var latLng = new google.maps.LatLng(dataPhoto.latitude,dataPhoto.longitude);
latlngbounds.extend( latLng );
var marker = new google.maps.Marker({
position: latLng,
icon: 'http://www.irishcottageholidays.com/images/cottage1.png'
});
listenMarker(map,marker,InfoWindow,dataPhoto.mID)
markers.push(marker);
}
然后创建智能信息窗口:
function listenMarker (map,marker,InfoWindow,mID){
google.maps.event.addListener(marker, 'click', function() {
load_content(map,this,InfoWindow,mID);
});
function load_content(map,marker,InfoWindow,mID){
var $j = jQuery.noConflict();
$j.ajax({
type : 'GET',
url : '/ajax/map_popup.asp',
data: {
mID : mID
},
success: function(result){
new SmartInfoWindow({position: marker.getPosition(), map: map, content: result});
}
});
}
最初我使用以下方法创建信息窗口:
InfoWindow.setOptions({
disableAutoPan: true,
maxWidth: 280
});
InfoWindow.setContent(result);
InfoWindow.open(map, marker);
这有效,但现在我已更改为 smartinfowindow,它加载了 infowindow 但位置不正确。
提前感谢所有帮助。
---- 编辑----
我现在遇到一个问题,即在打开另一个时 smartinfowindow 没有关闭,并且到目前为止还无法实现。到目前为止,我发现的所有内容似乎都适用于标准信息窗口,并且不适用于智能信息窗口。
再次感谢您提前提供的所有帮助。
【问题讨论】:
标签: javascript css google-maps infowindow