我一直有這個問題一段時間。我不斷收到此錯誤:Uncaught TypeError:Object#<InfoBox> has no method'open'
Uncaught TypeError: Object # has no method 'open'
這則訊息的解決方案並沒有真正幫助的。 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>
如果有人知道有什麼想法,請諮詢。在此先感謝
我,因爲我使用gae python來構建它,它可能是文件路徑問題以及我不知道gae導致問題的東西。 – tipsywacky
有同樣的問題,我複製了幾乎所有代碼示例,只是不會工作 – DanFromGermany