Uncaught TypeError: Object # <InfoBox> has no method 'open'

I have had this problem for some time now. I keep getting this error:

Uncaught TypeError: Object # has no method 'open'

The solution in this post doesn't help either. Uncaught TypeError: Object [object Object] does not have an 'open' method .

<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 knows how there are ideas please advice. thanks in advance

+3


source to share


1 answer


It's simple. You are calling "open ()" from some object that does not support it.

There are only two places in your code that you call "open ()" and in the first you are using an uninitialized variable ib.



That being said, if you're using Chrome's debugging tools, it should be very easy to track down.

-1


source







All Articles