我有GPS跟踪服务器,并且数据库中添加了MarkerManager的清除标记问题。我的截断代码:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<script src='http://maps.google.com/maps?file=api&v=2&hl=pl&key=my_key' type='text/javascript'></script>
</head>
<body onload='mapStart()' onunload='GUnload()'>
<script type='text/javascript'>
var map;
var mgr=false;
var timeOut=null;
function mapStart()
{
if(GBrowserIsCompatible())
{
map = new GMap2(document.getElementById("map"),{mapTypes: [G_NORMAL_MAP,G_HYBRID_MAP,G_SATELLITE_MAP,G_PHYSICAL_MAP]});
center = new GLatLng(52.536395, 13.42534);
map.setCenter(center, 6);
mgr = new GMarkerManager(map,{maxZoom: 19});
refreshMarkers();
}
}
function refreshMarkers()
{
clearTimeout(timeOut);
GDownloadUrl('dane2.php', function(dane,respCode)
{
if(respCode==200)
{
var xml = GXml.parse(dane);
var marker = dodajMarker(arguments, 15, 15);
}
else
{
alert('Cant open dane2.php');
}
});
mgr.clearMarkers(); // ???
timeOut=setInterval("refreshMarkers()",2000);
}
function dodajMarker(arguments, minZoom, maxZoom)
{
var ikona = new GIcon();
ikona.image = 'http://www.google.com/intl/en_ALL/mapfiles/dd-start.png';
ikona.iconSize = new GSize(20, 34);
ikona.iconAnchor = new GPoint(10, 34);
var marker = new GMarker(new GLatLng(latitude,longitude),{icon: ikona});
mgr.addMarker(marker,minZoom,maxZoom);
return marker;
}
</script>
<div id="map" style="align: center; width: 1000px; height: 490px; solid black; background: gray;"></div>
</body>
</html>
我的页面:http://m2mgsm.com/gps/index.php您可以登录:“admin”,密码:“12345”点击菜单中的测试地图(“Mapatesty” - 仅限波兰语,英文),然后选择IMEI(“Wybierz IMEI”) )例如355832010123229并检查Route(“Pokażtrasę:”)和From / To(“Od / Do”)日期(例如05.01.2012 / 05.01.2012)和“Filtruj”。您现在可以在框架中查看我的地图脚本的来源。我想刷新标记,例如, 3秒间隔和它的工作原理,但旧标记上的新标记是OVERLAY ... PS。抱歉我的英文。
答案 0 :(得分:2)
你的错误是你的JS:
ReferenceError: kontener is not defined [http://m2mgsm.com/gps/mapatesty.php:259]
TypeError: Object #<yv> has no method 'clearMarkers' [http://m2mgsm.com/gps/mapatesty.php:459]
尝试使用带有Firebug扩展程序的Firefox或带有内置调试程序的Chrome来跟踪JavaScript代码并消除错误。