完整 htmlogmap
地图代码的链接: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文件如下:
谷歌地图 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>