0

Exception was thrown at line 75, column 38 in https://maps.googleapis.com/maps-api-v3/api/js/23/7/util.js 0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'hasAttribute'

This runs inside a forms.webbrowser the window.external..... is being populated from the vb.net code and is appering to work correctly. some functions are called from that vb.net code and are not called in the html document.

If i could get help understanding what that script error is and how to kill it off that would be great.

NOTE: The code functioned properly until 3.19 of the google maps API was removed.

<!DOCTYPE html>
<html>
<head>
    <title>Site Finder Map</title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <style>
        html, body {
            height: 100%;
            margin: 0;
            padding: 0;
        }

        #map-canvas, #map_canvas {
            height: 100%;
        }

        @media print {
            html, body {
                height: auto;
            }

            #map-canvas, #map_canvas {
                height: 800px;
                width: 800px;
            }
        }

        #panel {
            position: absolute;
            top: 5px;
            left: 50%;
            margin-left: -180px;
            z-index: 5;
            background-color: #fff;
            padding: 5px;
            border: 1px solid #999;
        }
    </style>
    <style>
        #directions-panel {
            height: 100%;
            float: right;
            width: 49%;
            overflow: auto;
        }

        #map-canvas {
            margin-right: 50%;
        }

        @media print {
            #map-canvas {
                position: absolute;
                top: 50%;
                left: 50%;
                width: 600px;
                height: 600px;
                margin-left: -300px;
                margin-top: -300px;
            }
        }
    </style>
</head>
<body bgcolor="silver">
    <div id="directions-panel"></div>
    <div id="map-canvas"></div>

    <script src="https://maps.googleapis.com/maps/api/js?v=3&BLAHBLAHBLAH"></script>
    <script>
        var map;
        var marker;
        var geocoder;
        var panorama;
        var noaddressonmarkerchange = false;

        //
        // initialize
        //
        function initialize() {

            var latlon;
            var address;
            var lat;
            var lon;
            var bCheckAddress = false;

            geocoder = new google.maps.Geocoder();
            lat = parseFloat(window.external.MarkerLat);
            lon = parseFloat(window.external.MarkerLon);
            if ((lat < 0.1) || (lon > -0.1)) {
                //bCheckAddress = true;
                lat = parseFloat(window.external.HomeLat);
                lon = parseFloat(window.external.HomeLon);
            }
            noaddressonmarkerchange = true;
            latlon = new google.maps.LatLng(lat, lon);
           
            debugger;
            createMap(latlon);
            debugger;
            setDivider();

            if (bCheckAddress) {
                address = window.external.Address + ', ' +
                            window.external.City + ', ' +
                            window.external.State + ' ' +
                            window.external.Zip;
                geocoder.geocode({ 'address': address }, function (results, status) {
                    var latlon;

                    if (status == google.maps.GeocoderStatus.OK) {
                        latlon = results[0].geometry.location;
                        map.setCenter(latlon);
                        marker.setPosition(latlon);
                    }
                    else {
                        alert('Could not find location for:\n\n' + address + '\n\nStatus: ' + status);
                    }
                });
            }

            setTimeout(marker_poschanged, '2000');                  // force address lookup
        }


        //
        // setLocation
        //
        function setLocation() {
            debugger;
            var latlon;
            var lat = parseFloat(window.external.MarkerLat);
            var lon = parseFloat(window.external.MarkerLon);

            noaddressonmarkerchange = true;
            latlon = new google.maps.LatLng(lat, lon);
            map.setCenter(latlon);
            marker.setPosition(latlon);
        }


        //
        // createMap
        //
        function createMap(latlon) {

            var mapOptions = {                                      // create map
                zoom: parseInt(window.external.ZoomLevel, 10),
                center: latlon,
                mapTypeId: window.external.MapType
            };

            var mapDiv = document.getElementById('map-canvas');
            map = new google.maps.Map(mapDiv, mapOptions);
            marker = new google.maps.Marker({                       // create marker
                position: latlon,
                map: map,
                draggable: false,
                title: ''
            });
            document.getElementById('directions-panel').style.width = '100px';
            var panoramaOptions = {
                position: latlon,
                addressControl: false,
                pov: {
                    heading: 0,
                    pitch: 10
                }
            };
            debugger;

            panorama = new google.maps.StreetViewPanorama(document.getElementById('directions-panel'), panoramaOptions);
            map.setStreetView(panorama);

            google.maps.event.addListener(map, 'rightclick', mouse_rightclick);
            google.maps.event.addListener(map, 'mousemove', mouse_move);
            google.maps.event.addListener(map, 'mouseout', mouse_out);
            google.maps.event.addListener(map, 'zoom_changed', map_zoomchanged);
            google.maps.event.addListener(map, 'maptypeid_changed', map_typeidchanged);
            google.maps.event.addListener(marker, 'position_changed', marker_poschanged);
        }

        //
        // map_typeidchanged
        //
        function map_typeidchanged() {
            window.external.MapType = map.getMapTypeId();
        }

        //
        // map_zoomchanged
        //
        function map_zoomchanged() {
            window.external.ZoomLevel = map.getZoom().toString();
        }

        //
        // marker_poschanged
        //
        function marker_poschanged() {
            debugger;
            if (!noaddressonmarkerchange) {
                codeLatLng(marker);
                window.external.MarkerLat = marker.getPosition().lat().toFixed(6).toString()
                window.external.MarkerLon = marker.getPosition().lng().toFixed(6).toString()
            }
            panorama.setPosition(marker.getPosition());
            if (panorama.getVisible() == false) panorama.setVisible(true);
            noaddressonmarkerchange = false;
        }

        //
        // mouse_rightclick
        //
        function mouse_rightclick(e) {
            marker.setPosition(e.latLng);
        }

        //
        // mouse_move
        //
        function mouse_move(e) {
            window.external.MovingLatLon = e.latLng.lat().toFixed(6).toString() + ' , ' +
                                            e.latLng.lng().toFixed(6).toString();
        }

        //
        // mouse_out
        //
        function mouse_out(e) {
            window.external.MovingLatLon = '';
        }

        //
        // findAddress
        //
        function findAddress(fulladdress) {
            debugger;
            geocoder.geocode({ 'address': fulladdress }, function (results, status) {
                var latlon;

                if (status == google.maps.GeocoderStatus.OK) {
                    latlon = results[0].geometry.location;
                    map.setCenter(latlon);
                    marker.setPosition(latlon);
                }
                else {
                    alert('Could not find location for:\n\n' + fulladdress + '\n\nStatus: ' + status);
                }
            });
        }

        //
        // codeLatLng
        //
        function codeLatLng(markee) {
            debugger;
            var m_address;
            var m_city;
            var m_state;
            var m_zip;
            var m_country;

            m_address = '';
            m_city = '';
            m_state = '';
            m_zip = '';
            m_country = '';
            geocoder.geocode({ 'latLng': markee.getPosition() }, function (results, status) {
                var icnt;
                var jcnt;
                if (status == google.maps.GeocoderStatus.OK) {
                    if (results[0]) {
                        //window.external.title = results[0].formatted_address;
                        document.title = results[0].formatted_address;
                        for (icnt = 0; icnt < results[0].address_components.length; icnt++) {
                            var res = results[0].address_components[icnt];
                            for (jcnt = 0; jcnt < res.types.length; jcnt++) {
                                if (res.types[jcnt] == 'street_number') {
                                    m_address = res.short_name + m_address;
                                }
                                else if (res.types[jcnt] == 'route') {
                                    m_address = m_address + ' ' + res.short_name;
                                }
                                else if (res.types[jcnt] == 'postal_code') {
                                    m_zip = res.short_name;
                                }
                                else if (res.types[jcnt] == 'locality') {
                                    m_city = res.short_name;
                                }
                                else if (res.types[jcnt] == 'administrative_area_level_1') {
                                    m_state = res.short_name;
                                }
                                else if (res.types[jcnt] == 'country') {
                                    m_country = res.short_name;
                                }
                            }
                        }
                        markee.setTitle(m_address + '\n' + m_city + ', ' + m_state + '  ' + m_zip);
                        window.external.Address = m_address;
                        window.external.City = m_city;
                        window.external.State = m_state;
                        window.external.Zip = m_zip;
                        window.external.Country = m_country;
                    }
                    else {
                        markee.setTitle('No address found');
                    }
                }
                else {
                    markee.setTitle('Geocoder failure: ' + status);
                }
            });
        }

        function setHomeLocation() {
            debugger;
            window.external.HomeLat = marker.getPosition().lat().toFixed(6).toString()
            window.external.HomeLon = marker.getPosition().lng().toFixed(6).toString()
        }

        function setDivider() {
            debugger;
            var mr = 100 - window.external.MapPct;
            var mapwidth = Math.floor(document.body.clientWidth * mr / 100);
            var dirwidth = Math.floor((document.body.clientWidth * mr / 100) - 5);

            document.getElementById('map-canvas').style.marginRight = mapwidth.toString() + 'px';
            document.getElementById('directions-panel').style.width = dirwidth.toString() + 'px';
            google.maps.event.trigger(map, "resize");
            google.maps.event.trigger(panorama, "resize");
        }

        google.maps.event.addDomListener(window, 'load', initialize);
    </script>
</body>

</html>

2
  • window.external..... is being populated from the vb.net code and is appering to work correctly .... I don't know how it's populated, but when I remove the values from window.external with some fixed values everything works correct for me(no errors)..... so check the properties of window.external
    – Dr.Molle
    Feb 25, 2016 at 23:49
  • Update for this was that google maps API stopped supporting IE 7 the default browser version used when inside a windows forms application is set in the registry. it can be programmatically updated or permanently changed. Apr 19, 2016 at 22:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy