https://maps.googleapis.com/maps-api-v3/api/js/23/7/util.js第38行第75行引发了异常 0x800a01b6 - JavaScript运行时错误:对象不支持属性或方法' hasAttribute'
这在forms.webbrowser中运行window.external .....正在从vb.net代码中填充,并正在运行正常。某些函数是从该vb.net代码调用的,并未在html文档中调用。
如果我可以帮助了解该脚本错误是什么以及如何将其删除那将是很好的。
注意:代码正常运行,直到google maps API的3.19被删除。
<!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>
&#13;