<script type="text/javascript" src="http://maps.api.2gis.ru/1.0"></script>
<script type="text/javascript">

var lat1 = 0;
var lon1 = 0;
var Datetime;// "01.01.0001 00:00"
var Speed = 0;
var ClearFlag = 0;
var MapNeedMove = 1;
var TrackNeedDraw = 0;
var start = false;
var line = false;
var Alias;

var old_lat = 0;
var old_lon = 0;

window.onload = function () {
	map = new DG.Map('myMapId');
	setInterval(movePlacemark, 500);
}

function movePlacemark()
{
	if(lat1)
	{
		if(!start)
		{
			map.setCenter(new DG.GeoPoint(lon1, lat1));
			map.zoomTo(13); 
			map.controls.add(new DG.Controls.Zoom());
		        myMarker = new DG.Markers.MarkerWithBalloon({ 
		                geoPoint: new DG.GeoPoint(lon1, lat1), 
				balloonOptions: ({ 
						shouldHideIcon: true,  
						contentHtml: '<B>' + Alias + '</B>' + '<BR>' + Datetime + '<BR>' + Speed + 'км/ч'})
			}); 
//myMarker.balloonOptions.adjustMapCenterToBalloon = false;
// Добавить маркер: 
		        map.markers.add(myMarker);
			start = true;
		}
		if(lat1 != old_lat || lon1 != old_lon)
		{
			pt=myMarker.getPosition();
       			pt.setLon(lon1);
       			pt.setLat(lat1);
        		myMarker.setPosition(pt);
			myMarker.setBalloonContent('<B>' + Alias + '</B>' + '<BR>' + Datetime + '<BR>' + Speed + 'км/ч');
			if(TrackNeedDraw == 1)
			{
				if(!line)
				{
					style = new DG.Style.Geometry();
					style.strokeColor = "red";
					style.strokeOpacity = 1;
					style.strokeWidth = 4;
					var pointSet = [new DG.GeoPoint(lon1, lat1), new DG.GeoPoint(lon1, lat1)];
					line = new DG.Geometries.Polyline(pointSet, style);
// Добавим на карту:
					map.geometries.add(line);
				}
				line.addPoint(new DG.GeoPoint(lon1, lat1));
			}
//			if(MapNeedMove == 1)
//			{Не удается не центровать карту       	
//			}
			old_lat = lat1;
			old_lon = lon1;
		}
	}
}
</script>

<BODY>
<div id="myMapId" style="width:100%;height:100%"></div>
</BODY>