学习使用MapBar2--点击地图以后,点击回放,会回放点击的点

代码

<! DOCTYPE html PUBLIC  " -//W3C//DTD XHTML 1.0 Strict//EN "   " http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd " >
< html xmlns = " http://www.w3.org/1999/xhtml " >
< head >
    
< title > 历史轨迹显示    ~~~~~~~~</ title >

    
< script type = " text/javascript "  src = " http://api.mapbar.com/api/mapbarapi31.2.js " ></ script >

    
< script type = " text/javascript " >
var maplet 
=   null ;
 var MyPoint 
=   null ;
 var marker 
=   null ;
 var counter 
=   0 ;
   var Start00MyPoint 
= null ;
   var timerId 
=   null ;
function initMap(){
maplet 
=   new  Maplet( " mapbar " );
maplet.centerAndZoom(
new  MPoint( " 武汉市 " ),  9 );
maplet.showOverview(
false );
marker 
=   new  MMarker(
    
new  MPoint( " 武汉市 " ),
    
new  MIcon( " http://img.mapbar.com/maplite/mapbank/ditu/image/icon/maplite/gif1/tb1.gif " 32 32 16 32 )
    );

maplet.addOverlay(marker);
    MEvent.addListener(maplet, 
" pan " , function() {
        var center 
=  maplet.getCenter();
        
if (MyPoint != null )
            MyPoint 
+= center  +   " , " ;
        
else
            MyPoint 
=  center  +   " , " ;
    });
}

function Start00()
{
    
if (timerId != null )
        window.clearInterval(timerId);
    counter 
=   0 ;
    Start00MyPoint 
=  MyPoint.split( " , " );
    timerId 
=  window.setInterval(updatePos, 1000 );
}


function updatePos() {



if (counter < Start00MyPoint.length - 1 ) {
marker.setPoint(
new  MPoint(Start00MyPoint[counter]));

counter 
++ ;

}


    
</ script >

</ head >
< body onload = " initMap() " >
    
< div id = " mapbar "  style = " width: 800px; height: 500px " >
    
</ div >
    
< input type = " button "   onclick = " Start00(); "  value = " 开始回放 "   />
</ body >
</ html >

 

 

 

 

你可能感兴趣的:(map)