1

我有 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&amp;v=2&amp;hl=pl&amp;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 秒。间隔并且它有效,但是新标记覆盖在旧标记上...... Ps。对不起我的英语不好。

4

1 回答 1

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 代码并消除错误。

于 2012-01-09T10:29:29.013 回答