这个问题我已经有一段时间了。我不断收到此错误:
未捕获的类型错误:对象 # 没有“打开”方法
这篇文章中的解决方案也没有真正的帮助。Uncaught TypeError: Object [object Object] has no method 'open'。
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=xxxxxx&sensor=false&callback=initializeMap"></script>
<script type="text/javascript" src="/js/infobox_packed.js"></script>
<script type="text/javascript">
var marker1;
function initializeMap() {
var latlng = new google.maps.LatLng(22.3113315, 114.188804);
var myMapOptions = {
zoom: 11,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myMapOptions);
marker1 = new google.maps.Marker({
map: map,
draggable: false,
position: new google.maps.LatLng(22.283378, 114.183826),
visible: true
});
var boxText = document.createElement("div");
boxText.style.cssText = "border: 1px solid black; margin-top: 8px; background: white; padding: 5px;";
boxText.innerHTML = "Need help on moving home.<br>Wan Chai<br>Hong Kong";
var myOptions = {
content: boxText,
disableAutoPan: false,
maxWidth: 0,
pixelOffset: new google.maps.Size(-140, 0),
zIndex: null,
boxStyle: {
background: "url('tipbox.gif') no-repeat",
opacity: 0.75,
width: "280px"
},
closeBoxMargin: "10px 2px 2px 2px",
closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif",
infoBoxClearance: new google.maps.Size(1, 1),
isHidden: false,
pane: "floatPane",
enableEventPropagation: false
};
google.maps.event.addListener(marker1, "click", function (e) {
ib.open(map, this);
});
var ib = new InfoBox(myOptions);
ib.open(map, marker1);
}
</script>
如果有人知道如何有任何想法,请指教。提前致谢