
var map;//地图
var marker = new Array();//标记数组
var fLatitude;
var fLongitude;
var nMapZoon = 4;
var Centerid = -1;//跟踪点标记
var bCenter = 0;//居中
var bInit = 0;

    document.write("<script src ='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAfbAqOoQTJqDAJUybPG2WKBQ9-mbU9QWkEW9MNChgKEvUVPaRTBQHZm-j3OP0Gqpx6PU-rWUXk1-JjA&hl=zh-CN&tab=ml' type='text/javascript'></script>");
    fLatitude = 34.3797125804622;
    fLongitude = 104.150390625;



 function load() 
 { 
	if (GBrowserIsCompatible()) 
	{ 
       map = new GMap2(document.getElementById("map"));
	   var customUI = new GMapUIOptions(); 
       customUI.maptypes = {}; 
       customUI.zoom = {}; 
       customUI.controls = {}; 
       customUI.maptypes.normal = true; 
       customUI.maptypes.satellite = true; 
       customUI.zoom.doubleclick = true; 
       customUI.zoom.scrollwheel = true; 
	   customUI.controls.largemapcontrol3d = true;
       customUI.controls.menumaptypecontrol = true; 
       map.setUI(customUI); 
       map.addControl(new GOverviewMapControl());
	   map.setCenter(new GLatLng(fLatitude, fLongitude), nMapZoon);
	   bInit = 1;
	 }
 } 
 function NoTrace(id)
 {
 	if( marker[id] == null || bInit == 0)
	{
		return;
	}
	map.setZoom(4);
	bCenter = 0;
//	label[Centerid].setClassname("style1");
 }
 function Trace(id)
 {
 	if( marker[id] == null || bInit == 0 )
	{
		return;
	}
	if( bCenter == 1 )
	{
		NoTrace(Centerid);
	}
	else
	{
	    Centerid = id;
	    bCenter = 1;
	    map.setZoom(13);
	    map.setCenter( marker[Centerid].getPoint() );
	}
//	label[Centerid].setClassname("style2");
 }
 function RemoveMarker( id )
 {
 	if( marker[id] == null || bInit == 0)
	{
		return;
	}
	map.removeOverlay( marker[id] );
	marker[id] = null;
 }
 function ShowInfoWindow(id, strID, strUserName, strAlarm, strChannel, strZone, strArea, strTime)
 {
   	var font1 = '<font color="#000000" style="FONT-SIZE: 9pt">';
	var font2 = '<font color="#FF0000" style="FONT-SIZE: 9pt">';
	var font3 = '<font color="#00FF00" style="FONT-SIZE: 9pt">';
    var info = '';
    info = font1;

        info +=  '&nbsp;&nbsp;&nbsp;&nbsp;ID:&nbsp;' + font2 + strID + '<br>';
        info += font1 + '名称:&nbsp;'+ font2 + strUserName +'<br>';
        info += font1 + '警情:&nbsp;'+ font2 + strAlarm + '<br>';
        info += font1 + '通道:&nbsp;'+ font2 + strChannel + '<br>';
        info += font1 + '防区:&nbsp;'+ font2 + strZone + '<br>';
        info += font1 + '分区:&nbsp;'+ font2 + strArea + '<br>';
        info += font1 + '时间:&nbsp;'+ font2 + strTime + '<br>' + '<br>';
        info += font3+ '<a href="javascript:Trace('+ id +')">追踪</a>';

    
    marker[id].openInfoWindowHtml(info);
	GEvent.addListener(marker[id], "click", function(pixel) 
 	{
        marker[id].openInfoWindowHtml(info);
	 }); 
 }

  //创建标记
 function MoveMarker(id, strID, strUserName, strAlarm, strChannel, strZone, strArea, strTime, dx, dy)
 { 
 	if( 0 == bInit )
	{
		alert("unInit");
		return;
	}
	if ( map.getCurrentMapType() == G_NORMAL_MAP)
	{
		dx = parseFloat(dx);
		dy = parseFloat(dy);
	}

	var point = new GLatLng(dx, dy); 
	
	if( marker[id] == null)
	{
		marker[id] = new GMarker(point/*,icon*/);
		map.addOverlay(marker[id]); 
		map.setCenter(point, 4);
		Centerid = id;
	}
	else
	{
		if( id != Centerid)
		{
			map.setCenter(point);
		} 
	}
	ShowInfoWindow(id, strID, strUserName, strAlarm, strChannel, strZone, strArea, strTime);
 } 