如何在
theStore
点击事件上将特定标记位置 #street
的街景添加到地图上?
<button type="button" class="btn btn-default btn-sm" id="street">Street View</button>
JavaScript:
var theStore = {lat: -25.363, lng: 131.044};
var marker = new google.maps.Marker({
position: theStore,
map: map
});
google.maps.event.addDomListener(street, 'click', function () {
//Display Street View of theStore
});
您只需将位置设置为特定标记的位置即可:
panorama = map.getStreetView();
panorama.setPosition(theStore);
panorama.setVisible(true);