我最近是 google map api v3 的新手,想问一下是否有什么方法可以通过单击我的 infoBox 中的链接来触发街景模式。
到目前为止,这是我的代码:
var map;
var marker;
var infowindow;
function HomeControl(controlDiv, map) {controlDiv.style.margin = '50px 0 0 0';}
function initialize() {
var location = new google.maps.LatLng(37.78391, -122.407157);
var mapOptions = {
center: location,
zoom: 18,
panControl: false,
scrollwheel: false,
zoomControl: false,
scaleControl: true,
streetViewControl: true,
streetViewControlOptions: {
mapTypeControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP };
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
marker = new google.maps.Marker({position: map.getCenter(),
map: map,
title: 'Click to zoom'
});
var boxText = document.createElement("div");
boxText.style.cssText = "margin-top: 26px; background: url('inc/images/infowindow-overlay.png') repeat left top; padding: 15px 20px;";
boxText.innerHTML = "<span class='pointing-arrow'></span><h2 class='adress-title'>San Francisco Center</h2><a href='#'>Centre Website</a><a href='#'>Street View</a>";
var myOptions = {
content: boxText,
disableAutoPan: false,
maxWidth: 0,
pixelOffset: new google.maps.Size(-5, 0),
zIndex: null,
boxStyle: {width: "280px"}
};
map = new google.maps.Map(document.getElementById("map-canvas"),
mapOptions);
var image = 'inc/images/westfield-marker-logo.png';
marker = new google.maps.Marker({
position: location,
map: map,
title: 'Westfield HQ',
draggable: true,
icon: image
});
//infowindow.open(map,marker);
google.maps.event.addListener(marker, 'click', function() {
map.setZoom(18);
map.setCenter(marker.getPosition());
ib.open(map, this);
});
var ib = new InfoBox(myOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
现在我想做的是,在我初始化boxText并添加标记的部分,我希望街景锚标记初始化街景onclick。
我在文档中找到了一些选项,例如通过单击外部链接将地图居中到标记,但找不到任何可以在单击时激活街景的选项。