gpt4 book ai didi

google-maps - Onion.js 中的 Google map 脚本错误

转载 作者:行者123 更新时间:2023-12-04 00:12:48 25 4
gpt4 key购买 nike

今天早上我刚开始收到谷歌地图脚本错误。

线路:0
字符:0
错误:脚本错误
代码:0
网址:

我将所有代码更改恢复到早期版本,但它仍然存在。

我将包含下面的脚本,但我必须提到它在与 IE 接口(interface)的 Delphi TWebBrowser 中运行。

我可以运行我的程序,与页面交互,然后让它闲置。大约 20 秒后,在没有任何用户交互的情况下,我得到了上面的持续错误。当我关闭错误消息框时,它会立即打开并显示相同的消息。

我已经为这个项目工作了几个月,现在开始了。我已经回滚了几个版本,但它仍然存在。

我从哪里开始寻找?

<html>
<head>
<title>Find your Qtr minute locator</title>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?api=AIzaSyAa7YZpvi09ig92s_BLP2H3QVLTmoqdcQQ&amp;v=3.exp&amp;libraries=geometry&amp;sensor=false"></script>
</head>
<body><!-- Declare the div, make it take up the full document body -->
<div id="map-canvas" style="HEIGHT: 100%; WIDTH: 100%"></div>
<script type="text/javascript">
var map;
var idx = 0;
var qtrArray = [];
var userGridArray = [];
var Startlatlng = "";
var llOffset = 0.00416666666667;
var babyOffset = (llOffset/2); // offsets gridSelector 1/2 qtr min
var drawGridSelectBox = false;
var findNeighbor = false;
var firstRun = true;
var drawGridBox = false;
var deSelectOn = false;
var GridSelect = false;
var gridOverBox = new google.maps.Polygon();
var gridSelectBox = new google.maps.Polygon();

var gridline;
var polylinesquare;
var latPolylines = [];
var lngPolylines = [];
var lngLabels = [];
var otherColor = "#128A00";
var bounds = new google.maps.LatLngBounds();

function initialize() {
map = new google.maps.Map(document.getElementById("map-canvas"), {
center: new google.maps.LatLng(34.0, -84.0),
zoom: 14,
streetViewControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP,
scaleControl: true
});

google.maps.event.addListener(map, "click", function (event) {
if (!google.maps.geometry.poly.containsLocation(event.latLng, gridSelectBox)) {
map.setZoom(14);
if (findNeighbor)
MarkArea(event.latLng.lat(), event.latLng.lng());
if (drawGridSelectBox) {
createGridSelectBox(event.latLng);
GridSelect = !firstRun;
if (!GridSelect) {
ClearGrid()
}
}

for(var xx=0;xx<latPolylines.length;++xx){
for(var yy=0;yy<lngPolylines.length-1;++yy){
var latLng=new google.maps.LatLng(latPolylines[xx].getPath().getAt(0).lat(),
lngPolylines[yy].getPath().getAt(0).lng());

if ((google.maps.geometry.poly.containsLocation(latLng, gridSelectBox))&&(!firstRun))
{
drawGridBox = true;
createGridBox(latLng);
}
}
}
firstRun = false;
map.panTo(event.latLng);
drawGridBox = false;

}});

DrawGridOn();
google.maps.event.addListener(map, "idle", function () {
createGridLines(map.getBounds());
});
} // initialize

google.maps.event.addDomListener(window, "load", initialize);

function createGridLines(bounds) {
for (var i = 0; i < latPolylines.length; i++) {
latPolylines[i].setMap(null);
}

latPolylines = [];
for (var j = 0; j < lngPolylines.length; j++) {
lngPolylines[j].setMap(null);
}
lngPolylines = [];

for (var k = 0; k < lngLabels.length; k++) {
lngLabels[k].setMap(null);
}
lngLabels = [];

if (map.getZoom() < 10) return;
var north = bounds.getNorthEast().lat();
var east = bounds.getNorthEast().lng();
var south = bounds.getSouthWest().lat();
var west = bounds.getSouthWest().lng();

// define the size of the grid
var topLat = Math.ceil(north / llOffset) * llOffset;
var rightLong = Math.ceil(east / llOffset) * llOffset;

var bottomLat = Math.floor(south / llOffset) * llOffset;
var leftLong = Math.floor(west / llOffset) * llOffset;


var qtrNELatLngCode = ddToQM(topLat, rightLong);
var qtrNorth = qtrNELatLngCode.substring(0, 5);
var qtrEast = qtrNELatLngCode.substring(5, 12);
var qtrSWLatLngCode = ddToQM(bottomLat, leftLong);
var qtrSouth = qtrSWLatLngCode.substring(0, 5);
var qtrWest = qtrSWLatLngCode.substring(5, 12);

for (var latitude = bottomLat; latitude <= topLat; latitude += llOffset) latPolylines.push(new google.maps.Polyline({
path: [
new google.maps.LatLng(latitude, leftLong), new google.maps.LatLng(latitude, rightLong)],
map: map,
geodesic: true,
strokeColor: "#0000FF",
strokeOpacity: 0.1,
strokeWeight: 1
}));
for (var longitude = leftLong; longitude <= rightLong; longitude += llOffset) lngPolylines.push(new google.maps.Polyline({
path: [
new google.maps.LatLng(topLat, longitude), new google.maps.LatLng(bottomLat, longitude)],
map: map,
geodesic: true,
strokeColor: "#0000FF",
strokeOpacity: 0.1,
strokeWeight: 1
}));

if (map.getZoom() < 15) {
for (var l = 0; l < lngLabels.length; l++) {
lngLabels[l].setMap(null);
}
lngLabels = [];
return;
} // set lngLabels to null

for(var x=0;x<latPolylines.length;++x){
for(var y=0;y<lngPolylines.length-1;++y){
var latLng=new google.maps.LatLng(latPolylines[x].getPath().getAt(0).lat(),
lngPolylines[y].getPath().getAt(0).lng());

var qtrLatLng = ddToQM(latLng.lat(), latLng.lng());

lngLabels.push(new google.maps.Marker({
map:map,
position:latLng,
icon:{ url:"https://chart.googleapis.com/chart?"
+"chst=d_bubble_text_small&chld=bb|"
+ qtrLatLng
+"|FFFFFF|000000",
anchor:new google.maps.Point(0,42)
}
}));
}
}
external.ShowQtrMinBounds(qtrNorth, qtrSouth, qtrEast, qtrWest);
} // end createGridLines

function createGridSelectBox(point) {
// Square limits
var smPoint = point;

var bottomLeftLat = (Math.floor(point.lat() / llOffset) * llOffset) - babyOffset;
var bottomLeftLong = (Math.floor(point.lng() / llOffset) * llOffset) - babyOffset;


var gridLineSquare = [
new google.maps.LatLng(bottomLeftLat, bottomLeftLong), //lwr left
new google.maps.LatLng(bottomLeftLat, bottomLeftLong + llOffset), //lwr right
new google.maps.LatLng(bottomLeftLat + llOffset, bottomLeftLong + llOffset), //upr right
new google.maps.LatLng(bottomLeftLat + llOffset, bottomLeftLong)]; //upr left
//auto-complete to lwr left

if (drawGridSelectBox == true) {
gridSelectBox = new google.maps.Polygon({
path: gridLineSquare,
draggable:true,
geodesic:true,
editable :true,
fillColor: "#FF0000",
fillOpacity: 0.35,
strokeColor: "#CC0099",
strokeOpacity: 0.1,
strokeWeight: 1
});

gridSelectBox.setMap(map);
drawGridSelectBox = false;
}
}

function MarkArea(Lat, Lng) {
var latLng = new google.maps.LatLng(Lat,Lng);
drawUserGrids(latLng);
}

function SaveQtrMin(){
for (var m in qtrArray) {
external.SaveQtrMinutes(qtrArray[m].qtrMinute);
}
}

function DrawGridOn() { //creates GridSelectBox
addGridOn = false;
drawGridSelectBox = true;
firstRun = true;
}

function DrawGridOff() {
gridSelectBox.setMap(null);
drawGridSelectBox = false;
}

function GotoLatLng(Lat, Lng) {
var latlng = new google.maps.LatLng(Lat,Lng);
map.setCenter(latlng);
}

function DeSelectOn(){
deSelectOn = true;
addGridOn = false;
}

function DeSelectOff(){ // Allows removing 1 QtrMin
deSelectOn = false;
}

function AddGridOn(){ // Allows adding 1 QtrMin
addGridOn = true;
deSelectOn = false;
}

function AddGridOff(){
addGridOn = false;
}

function ClearGrid() {
if (qtrArray) {
for (var i in qtrArray) {
qtrArray[i].setMap(null);
}
}
qtrArray=[];
idx = 0;
}

function ClearUserGrid() {
if (userGridArray) {
for (var i in userGridArray) {
userGridArray[i].setMap(null);
}
}
userGridArray=[];
}

function drawUserGrids(point) {
// Square limits

var bottomLeftLat = (Math.floor(point.lat() / llOffset) * llOffset);
var bottomLeftLong = (Math.floor(point.lng() / llOffset) * llOffset);

var gridLineSquare = [
new google.maps.LatLng(bottomLeftLat, bottomLeftLong), //lwr left
new google.maps.LatLng(bottomLeftLat, (bottomLeftLong + llOffset)), //lwr right
new google.maps.LatLng((bottomLeftLat + llOffset), (bottomLeftLong + llOffset)), //upr right
new google.maps.LatLng((bottomLeftLat + llOffset), bottomLeftLong)]; //upr left


drawGridBox = true;

if (drawGridBox == true) {

gridUserArea = new google.maps.Polygon({
path: gridLineSquare,
draggable:false,
geodesic:true,
editable :false,
fillColor:otherColor,
fillOpacity: 0.35,
strokeColor: "#CC0099",
strokeOpacity: 0.1,
strokeWeight: 1
});

gridUserArea.setMap(map);
userGridArray.push(gridUserArea);
}
}

function createGridBox(point) {
// Square limits
var arrayIdx = 0;
var addListenersOnPolygon = function(polygon) {
google.maps.event.addListener(polygon, 'click', function (event) {
if (deSelectOn==true) {
arrayIdx = qtrArray.indexOf(polygon);
qtrArray.splice(arrayIdx,1);
polygon.setMap(null);
}
});
};
var smPoint = point;

var bottomLeftLat = (Math.floor(point.lat() / llOffset) * llOffset);
var bottomLeftLong = (Math.floor(point.lng() / llOffset) * llOffset);


var gridLineSquare = [
new google.maps.LatLng(bottomLeftLat, bottomLeftLong), //lwr left
new google.maps.LatLng(bottomLeftLat, (bottomLeftLong + llOffset)), //lwr right
new google.maps.LatLng((bottomLeftLat + llOffset), (bottomLeftLong + llOffset)), //upr right
new google.maps.LatLng((bottomLeftLat + llOffset), bottomLeftLong)]; //upr left
drawGridBox = true;

if (drawGridBox == true) {
gridOverBox = new google.maps.Polygon({
path: gridLineSquare,
draggable:false,
geodesic:true,
editable :false,
fillColor: "#EAED00",
fillOpacity: 0.35,
strokeColor: "#CC0099",
strokeOpacity: 0.1,
strokeWeight: 1,
qtrMinute : ddToQM(bottomLeftLat, bottomLeftLong),
indexID : ++idx
});

gridOverBox.setMap(map);
addListenersOnPolygon(gridOverBox);
qtrArray.push(gridOverBox);
}
}

function ddToQM(alat, alng) {
var latResult, lngResult, dmsResult;

alat = parseFloat(alat);
alng = parseFloat(alng);

latResult = "";
lngResult = "";

latResult += getDms(alat);
lngResult += getDms(alng);

dmsResult = latResult + lngResult;

// Return the resultant string.
return dmsResult;
}

function toggleGridSelection(){
GridSelect = true;//(!!GridSelect);
}

function findNeighborOn(){
findNeighbor = true;
otherColor = randColor();
}

function findNeighborOff(){
findNeighbor = false;
otherColor = "#128A00";
}

function randColor() {
var i;
var colorArray = ["#B2A209","#A4A07B","#B02600","#6CA200","#BC0072","#B1ADFF","#16CADB","#A1FFD1","#9999CC","#EEFF7C"];

i = Math.floor((Math.random() *10)+1);
return colorArray[i];
}

function getDms(val) {
// Required variables
var valDeg, valMin, valSec, interimResult;
var qtrMin;
val = Math.abs(val);

// ---- Degrees ----
valDeg = Math.floor(val);
valMin = Math.floor((val - valDeg) * 60);
valSec = Math.round((val - valDeg - valMin / 60) * 3600 * 1000) / 1000;

if (valSec == 60){
valMin +=1;
valSec = 0;
}
if (valMin == 60){
valMin +=1;
valSec = 0;
}
interimResult = valDeg+"";

if (valMin<10){
valMin = "0"+valMin;
}
interimResult += valMin + "";

switch(valSec){
case 0 : qtrMin = "A";
break;
case 15 : qtrMin = "B";
break;
case 30 : qtrMin = "C";
break;
case 45 : qtrMin = "D";
break;

}
interimResult += qtrMin;
return interimResult;
}

</script>
</body>
</html>

最佳答案

在标题部分添加以下元标记为我解决了这个问题。

 <meta http-equiv="X-UA-Compatible" content="IE=edge">
  • X-UA-Compatible 元标记允许网络作者选择什么
    页面应呈现为的 Internet Explorer 版本。
  • 边缘模式告诉 Internet Explorer 以最高模式显示内容
    可用的。
  • 关于google-maps - Onion.js 中的 Google map 脚本错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33974901/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com