<script src="http://developer.mapit.co.za/Docs/JavaScriptV3/deCarta.JS3.min.js"></script>
<link href="http://developer.mapit.co.za/Docs/JavaScriptV3/css/UI/LayerControl.css" rel="stylesheet">
<script src="http://developer.mapit.co.za/Docs/JavaScriptV3/js/UI/LayerControl.js"></script>
<script src="http://developer.mapit.co.za/Docs/JavaScriptV3/js/UI/ScaleControl.js"></script>
<link href="http://developer.mapit.co.za/Docs/JavaScriptV3/css/UI/ScaleControl.css" rel="stylesheet">
<script src="http://developer.mapit.co.za/Docs/JavaScriptV3/js/UI/ZoomControl.js"></script>
<link href="http://developer.mapit.co.za/Docs/JavaScriptV3/css/UI/ZoomControl.css" rel="stylesheet">
<script type="text/javascript">

var lat1 = 0.;
var lon1 = 0.;
var Datetime;
var Speed = 0;
var ClearFlag = 0;
var MapNeedMove = 1;
var TrackNeedDraw = 0;
var start = false;
var polyline = false;
var Alias;
var pin;
var Angle = 0;
var pinOverlay;
var shapeOverlay;
var polyline = 0;

var old_lat = 0.;
var old_lon = 0.;

window.onload = function () {
	setInterval(movePlacemark, 500);        
}

function movePlacemark()
{
	if(lat1)
	{
		if(!start)
		{
			deCarta.Core.Configuration.clientName = "as";
			deCarta.Core.Configuration.clientPassword = "c29c34a7b549e8cf6ca33c9d07b5653d";                               
				
			var controls = [];
		        controls.push(new deCarta.UI.LayerControl({position: 'rightTop'}));
		        controls.push(new deCarta.UI.ScaleControl({position: 'bottomLeft'}));
		        controls.push(new deCarta.UI.ZoomControl({position: 'rightTop'}));
			center = new deCarta.Core.Position(lat1 + "," + lon1);
				
			path = new Array();
			path.push(center.clone());

			pin = new deCarta.Core.Pin({imageSrc:"car1_1.png", xOffset:9, yOffset:18 ,position: center.clone(),text: '<B>' + Alias + '</B><BR>' + Datetime + '<BR>' + Speed + 'êì/÷'});
			pinOverlay = new deCarta.Core.MapOverlay({name: "Pins"});
			shapeOverlay = new deCarta.Core.MapOverlay({name: "Shapes"});

			map = new deCarta.Core.Map({zoom: 14, id: "map_canvas", center: center, controls: controls,onReady: function(map){
			map.addLayer(shapeOverlay);
			map.addLayer(pinOverlay);
		        pinOverlay.addObject(pin);

			}});

			start = true;
		}
		if(lat1 != old_lat || lon1 != old_lon)
		{
			center = new deCarta.Core.Position(lat1 + "," + lon1);
			pin.setPosition(center);
//			pin.setRotation(360 - Angle);
			pin.hideText();
			pin.setText('<B>' + Alias + '</B>' + '<BR>' + Datetime + '<BR>' + Speed + 'êì/÷');
			pin.showText();
			if(TrackNeedDraw == 1)
			{
				if(!polyline)
				{
					polyline = new deCarta.Core.Polyline({lineGeometry: path,strokeColor: '#FF0000'});
//					shapeOverlay.addObject(polyline);
				}
				else
				{
					path.push(center.clone());
					polyline = new deCarta.Core.Polyline({lineGeometry: path,strokeColor: '#FF0000'});
					shapeOverlay.removeObject(polyline);
					shapeOverlay.addObject(polyline);
				}
			}
			if(MapNeedMove == 1)
			{       	
       				map.centerOn(center);
			}
			old_lat = lat1;
			old_lon = lon1;
		}
	}
}
</script>

<BODY>
	<div id="map_canvas" style="width:1000;height:700"></div>
</BODY>