I have been having this problem for some time. I keep getting this error:
Uncaught TypeError: Object # has no method ‘open’
The solution in this post doesn’t really help either. 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>
If anyone know how has any idea, please advice. Thanks in advance
This is straightforward. You’re calling ‘open()’ from some object that doesn’t support it.
There’s only two places you call ‘open()’ in your code, and in the first you, use an uninitialized variable ib.
That being said, if you use Chrome’s debugging tools, this should be very easy to track down.