语法错误:html 映射文件中的解析错误 - ogmaps 引用错误:找不到变量:GUnload

SyntaxError: Parse error in html map file - ogmaps ReferenceError: Can't find variable: GUnload

本文关键字:错误 ogmaps 引用 变量 GUnload 找不到 映射 html 文件 语法      更新时间:2023-10-16

指向完整html ogmap地图代码的链接:http://code.google.com/p/earthhtml/source/browse/trunk/ogmap.html

此映射文件从所有浏览器打开(最小化和最大化浏览器一次后)

当它尝试从我的C++代码中执行它时,如下所示:

void MainScreen::on_button1_clicked()
{
    map->clearCoordinates();
    map->load(QUrl("file:///home/anisha/Desktop/fwdgooglemaps/ogmaps/ogmap.html"));
}

显示以下错误:

"SyntaxError: Parse error on line:1148 Source:file:///home/anisha/Desktop/fwdgooglemaps/ogmaps/ogmap.html"
"ReferenceError: Can't find variable: GUnload on line:186 Source:file:///home/anisha/Desktop/fwdgooglemaps/ogmaps/ogmap.html" 

此处显示行号 1148。

function preloadRasterTile (uris,tile,zoom,x,y,transparent,htmlList)
{
    var url = getTileUrl (uris,tile,zoom);
    transparent&&/MSIE 6/i.test (navigator.userAgent)?
    htmlList.push(['<div style="left:', 256*x, "px;top:", 256*y, "px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader (sizingMethod = crop, src = '", url, '"', '__src__ = "'+url+'"', "></div>"].join ("")) : htmlList.push (['<img style = "position:absolute; left:',256*x," px="px">'].join(""))
}

编辑:

我刚刚评论了第 186 行,引用错误消失了,但语法错误仍然存在。不涉及浏览器。我正在 qt 小部件上加载这个缓存的地图。

编辑2:


代码现在在此行上显示另一个错误: else if (0 < minzoom><widthinearthunits><heightinearthunits><actions.length>;i++)

在功能repositionInlineZoomControls .

JavaScript的index.html文件如下:

Google Maps JavaScript API 示例

<script type="text/javascript"> 
var map;    
var latlng            = new google.maps.LatLng (28.635308, 77.22496);
var directionsDisplay = new google.maps.DirectionsRenderer ();
var directionsService = new google.maps.DirectionsService ();
var pointsArray       = new Array();
var arrayToBeReturned = new Array();
function initialize ()
{
    var myOptions = 
    {
        zoom:4,
        center:latlng,
        mapTypeId:google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map (document.getElementById ("map"), myOptions);
    directionsDisplay.setMap (map); 
    }
    function addMarker (x, y)
{
    var initialPoint       = new google.maps.LatLng (x, y);
    var initialPointMarker = new google.maps.Marker ({
                                position:initialPoint,
                                map:map,
                                draggable:false,
                                flat:true
                                });
}
 var arrayMarkers = new Array();
var arrayIndex   = 0;
function Open(x, y)
{   var newPosition = new google.maps.LatLng (x, y);
    map.setCenter (newPosition);        
    directionsDisplay.setMap (map);

    google.maps.event.addListener (map, "click", 
                            function (event)
                            {
                                //alert("You clicked the map."+ event.latLng.toString(4));
                                arrayMarkers [arrayIndex] = event.latLng;
                                var s0  = event.latLng.lat();
                                var s1  = event.latLng.lng();
                                var s01 = new google.maps.LatLng (s0, s1);
                                var point1 = new google.maps.Marker ({
                                                                position:arrayMarkers [arrayIndex],
                                                                draggable:false,
                                                                map:map,
                                                                flat:true
                                                                }); 
                                if (arrayIndex == 1)
                                    displayRoute ();
                                arrayIndex++;
                            });
}
function displayRoute ()
 {
    var start = arrayMarkers [0];
    var end   = arrayMarkers [1];
    var request = {
                origin:start,
                destination:end,
                travelMode:google.maps.TravelMode.DRIVING
                };
    directionsService.route (request, 
                        function (result, status) 
                        {
                            if (status == google.maps.DirectionsStatus.OK)
                            {
                                directionsDisplay.setDirections (result);
                                pointsArray = result.routes[0].overview_path;
                                var i = 0;
                                var j = 0;
                                for (j = 0; j < pointsArray.length; j++)
                                {                                       
                                    arrayToBeReturned [i] = pointsArray[j].lat ();
                                    i++;
                                    arrayToBeReturned [i] = pointsArray[j].lng ();
                                    i++;
                                    var point1 = new google.maps.Marker ({
                                        position:pointsArray[j],
                                        draggable:false,
                                        map:map,
                                        flat:true
                                        });
                                }
                            }
                        });

    getCoordinates();
}
function getCoordinates ()
{       
    return arrayToBeReturned;
}
</script> 
</head>
<body onload="initialize()" topmargin="0" leftmargin="0">
<div id="map" style="width: 641px; height: 671px"></div>
<div id="directionsPanel" style="float:right;width:1000%;height 100%"></div>
</body>
</html> 

htmlList.push行至少看起来有点可疑,特别是引号的使用对我来说似乎不正确。似乎单引号和双引号在某处混合在一起。例如,传递给 AlphaImageLoader 的 src 参数以单引号开头,但以双引号结尾。

一般来说,在使用引号

时保持一致是一个好主意,即使可以同时使用双引号和单引号。从长远来看,这将有所帮助。

我可能会使用更冗长但更具可读性的函数。我试图解决引用问题:

function preloadRasterTile (uris,tile,zoom,x,y,transparent,htmlList) 
{
    var url = getTileUrl (uris,tile,zoom);
    if (transparent && /MSIE 6/i.test(navigator.userAgent)) {
        htmlList.push([
            '<div style="left:', 256*x, 'px;',
            'top:', 256*y, 'px;',
            'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader (sizingMethod = crop, src = "', url, '"', '__src__ = "'+url+'"', 
            '></div>'].join (""));
    } else {
        htmlList.push([
            '<img style = "position:absolute;',
            'left:', 256*x, 'px;">'].join(""));
    }
}