我遇到了这个很棒的小脚本,用于通过 stackoverflow 在引导选项卡中加载 gmap。
链接:http: //jsfiddle.net/B4zLe/49/
我尝试进行必要的更改以尝试将街景触发到另一个选项卡中,但我得到的只是一个空白。请任何种类的鞋底帮忙。
这是我的 gmap 代码(用于地图)
var map;
jQuery(function($) {
$(document).ready(function() {
var latlng = new google.maps.LatLng(-16.920728, 145.769219);
var myOptions = {
zoom: 12,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
console.dir(map);
google.maps.event.trigger(map, 'resize');
$('a[href="#themap"]').on('shown', function(e) {
google.maps.event.trigger(map, 'resize');
});
$('#myTab a[href="#themap"]').on('shown', function(){
google.maps.event.trigger(map, 'resize');
map.setCenter(latlng);
});
var contentString = '<div id="iw_content">'+
'<h4>16/63 Mcleod Street , Cairns City</h4>'+
'<div class="iw_content_block">QLD 4870</div>'+
'<div class="iw_content_block">More listings from <a href="/agent/leona-bonsey-14/">Leona Bonsey</a></div>'
'</div>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
var iconBase = '/public/images/';
var myShadow = {
url: iconBase + 'shadow.png',
anchor: new google.maps.Point(16, 34)
};
var marker = new google.maps.Marker({
map: map,
animation: google.maps.Animation.DROP,
icon: iconBase + '422marker.png',
shadow: myShadow,
position: latlng,
title: "16/63 Mcleod Street, Cairns City, QLD, 4870"
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
});
});
可以在这里看到一个演示http://www.422.com.au/property/apartment-qld-cairns+city-15032013172546
这就是我的街景地图(未成功加载街景)
function initialize() {
var latlng = new google.maps.LatLng(-16.920728, 145.769219);
var panoramaOptions = {
position: latlng,
pov: {
heading: 165,
pitch: 0
},
zoom: 1
};
var myPano = new google.maps.StreetViewPanorama(
document.getElementById('street_canvas'),
panoramaOptions);
myPano.setVisible(true);
}
google.maps.event.addDomListener(window, 'load', initialize);
感谢任何帮助。