语法错误:html 映射文件中的解析错误 - ogmaps 引用错误:找不到变量:GUnload
SyntaxError: Parse error in html map file - ogmaps ReferenceError: Can't find variable: GUnload
指向完整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(""));
}
}
相关文章:
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- vector.resize()中的分配错误
- 代码在main()中运行,但在函数中出现错误
- 释放错误后堆使用
- (C++)分析树以计算返回错误值的简单算术表达式
- Project Euler问题4的错误解决方案
- 我的字符计数代码计算错误.为什么
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 尝试导入pybind-opencv模块时出现libgtk错误
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 在某些循环内使用vector.push_back时出现分段错误
- MSVC多行宏编译器错误
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 为什么在运行时没有向我们提供有关分段错误的更多信息?
- 语法错误:html 映射文件中的解析错误 - ogmaps 引用错误:找不到变量:GUnload