我正在尝试添加一个带有 InfoWindow 的标记。该标记在两个地图(即街景和法线地图)中均可见。但是,InfoWindow 仅显示在法线地图中,但在街景中打开时不会显示。
firebug 控制台中没有错误。
编码 :
var a = google.maps;
var b = {
center: new a.LatLng(parseFloat(ll[0]),parseFloat(ll[1])),
zoom: zoom,
mapTypeId: a.MapTypeId.ROADMAP,
streetViewControl: true,
mapTypeControlOptions: {
mapTypeIds: [a.MapTypeId.ROADMAP, a.MapTypeId.SATELLITE, a.MapTypeId.TERRAIN]
},
panControl: false,
zoomControlOptions: {
style: a.ZoomControlStyle.SMALL
}
};
map = new a.Map(document.getElementById("map-canvas"), b);
panorama = map.getStreetView();
panorama.setPosition(new google.maps.LatLng(42.345573,-71.098326));
panorama.setPov(/** @type {google.maps.StreetViewPov} */({
heading: 270,
pitch: 0
}));
panorama.setVisible(false);
iw = new a.InfoWindow();
a.event.addListener(map, "click", function () {
if (iw) iw.close()
});
var g = new a.Marker({
position: c,
map: map,
clickable: true,
draggable: true,
optimized: false,
raiseOnDrag: false,
zIndex: highestOrder()
});
var description = "<h2>"+document.getElementById('marker-title').value+"</h2><br/><p style='width:200px;'>"+document.getElementById('marker-desc').value+"</p>";
a.event.addListener(g, "click", function () {
actual = g;
iw.setContent(description);
if(map.getStreetView().getVisible == true) {
iw.open(map.getStreetView(), this);
}
else {
iw.open(map, this);
}
});
a.event.addListener(g, "dragstart", function () {
if (actual == g) iw.close();
z_index += 1;
g.setZIndex(highestOrder())
})