Google Maps API로 약간의 스크립트를 작성했으며 Chrome 또는 IE에서 완벽하게 실행됩니다. 그러나 Excel의 웹 브라우저 컨트롤을 사용하여지도를 실행하려고하면 오류 메시지가 표시되고 페이지가 제대로로드되지 않습니다.
나는 거기에서 무슨 일이 일어나고 있는지 잘 모르겠습니다. 이 두 언어에 대한 경험이 전혀 없었기 때문에 JavaScript / HTML 코드에 문제가 있다고 생각합니다. 제공된 오류 메시지는 다음과 같습니다.
이 페이지의 스크립트에서 오류가 발생했습니다. 줄 : 0, 문자 : 0, 오류 : 스크립트 오류, 코드 : 0, URL : https://maps.gstatic.com/maps-api-v3/api/js/21/7/intl/en_au/main.js "
내 생각은 HTML 부분에 문제가 있지만 확실하지 않습니다.
내 코드는
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Circle & Info</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
<script>
var locations = [
['St. Martin Catholic School', ' 4228', 42.9698, -81.2537, ' 266', ' 386', 'FE7569', '-1', ''],
['St. John Catholic French Immersion School', ' 4045', 42.97827, -81.2335, ' 350', ' 334', 'FE7569', '-1', ''],
['St. Mary Choir Catholic School', ' 4244', 42.988, -81.2284, ' 231', ' 311', 'FE7569', '-1', ''],
['Holy Rosary Catholic School', ' 3312', 42.9663, -81.2302, ' 165', ' 234', 'FE7569', '-1', ''],
['St. Michael Catholic School, London', ' 4301', 43.0042, -81.2446, ' 182', ' 268', 'FE7569', '-1', ''],
['New School', ' 99999',42.9809401, -81.2548567, ' ', ' 100', '9', '0', 'Not']
];
var markers = [];
var map;
var circles = [];
var radius;
function initialize() {
radius = document.getElementById("radius_value").value;
if (radius == "" || isNaN(radius)) {
radius = 2;
}
radius = Number(radius * 1000);
var myOptions = {
center: new google.maps.LatLng(42.9809401, -81.2548567),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("default"), myOptions);
setMarkers(radius);
}
var bounds = new google.maps.LatLngBounds();
function setMarkers(radius) {
var i;
for (i = 0; i != markers.length; ++i) {
markers[i].setMap(null);
}
for (i = 0; i < locations.length; i++) {
var name = locations[i][0];
var sfis = locations[i][1];
var lat = locations[i][2];
var long = locations[i][3];
var ade = locations[i][4];
var otg = locations[i][5];
var pinColor = locations[i][6];
var Indicator = locations[i][7];
var Duplicate = locations[i][8];
var latlngset = new google.maps.LatLng(lat, long);
var pinImage;
if (Indicator==0){
pinImage = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_xpin_letter&chld=pin|N|"+pinColor,
new google.maps.Size(21, 34),
new google.maps.Point(0, 0),
new google.maps.Point(10, 34));
} else if (Indicator==-1) {
if (Duplicate=="Duplicate") {
pinImage = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_xpin_letter&chld=pin_sleft|"+(i+1)+"|"+pinColor,
new google.maps.Size(50, 34),
new google.maps.Point(0, 0),
new google.maps.Point(20, 34));
} else {
pinImage = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_xpin_letter&chld=pin|"+(i+1)+"|"+pinColor,
new google.maps.Size(50, 34),
new google.maps.Point(0, 0),
new google.maps.Point(10, 34));
}
} else {
if (Duplicate =="Duplicate") {
pinImage = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_xpin_letter&chld=pin_sright|"+Indicator+"|"+pinColor,
new google.maps.Size(50, 50),
new google.maps.Point(0, 0),
new google.maps.Point(0, 34));
} else {
pinImage = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_xpin_letter&chld=pin|"+Indicator+"|"+pinColor,
new google.maps.Size(50, 50),
new google.maps.Point(0, 0),
new google.maps.Point(10, 34));}
}
var marker = new google.maps.Marker({
map: map,
title: name,
draggable:true,
position: latlngset,
icon: pinImage,
animation: google.maps.Animation.DROP
});
markers.push(marker);
map.setCenter (marker.getPosition())
var populationOptions = {
strokeColor: '#FF0000',
strokeOpacity: 0.2,
strokeWeight: 2,
fillColor: '#FF0000',
fillOpacity: 0.1,
map: map,
center: latlngset,
radius: radius
};
var content = '<div id="content">' +
'<h1 id="firstHeading" class="firstHeading">' + name +'</h1>' +
'<div id="bodyContent">' +
'<p><b>SFIS ID:</b>' + sfis + '</p>' +
'<p><b>ADE:</b>' + ade + '</p>' +
'<p><b>OTG:</b>' + otg + '</p>' +
'</div>' +
'</div>';
var infowindow = new google.maps.InfoWindow()
google.maps.event.addListener(marker, 'click', (function(marker, content, infowindow) {
return function() {
infowindow.setContent(content);
infowindow.open(map, marker);
};
})(marker, content, infowindow));
new google.maps.Circle(populationOptions);
bounds.extend(markers[i].position);
map.fitBounds(bounds);
}
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body onload="initialize()">
<div style="position:fixed;top:10px;right:200px;z-index:2000">
<input type="text" id="radius_value">
<button onclick="initialize()">Change Radius (km)</button>
</div>
<div id="default" style="width:100%; height:100%"></div>
</body>
</html>
html 코드가 괜찮아 보이고 엑셀 코드가 내 서버에 파일을 업로드 한 문제 일 수 있다고 생각합니다. 웹 컨트롤에서 다음 코드를 시도해보십시오.
WebBrowser1.Navigate ("about:blank")
WebBrowser1.Navigate ("www.rachelgallen.com/googlemap.html")
또는
페이지에 cmd 버튼을 넣으십시오. 웹 컨트롤 위의 셀에 URL을 입력하십시오. cmd 버튼의 코드에서 linkname과 같은 변수를 선언하고 Range (cell)와 동일하게 설정합니다. 그런 다음 입력합니다 (예 : Sheet1은 시트의 이름이고 C1은 URL을 입력 한 위치).
linkname=Sheets("Sheet1").Range(C1)
Call Sheets("Sheet1").WebControl1.Navigate (linkname)
작동하는지 확인
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다