var map;            // 全局的地图对象

  function load() 
  {  
      if (GBrowserIsCompatible()) 
      {
           var elemMap = document.getElementById('map_canl');
           map = new GMap2(elemMap);
           // 给地图添加内置的控件，分别为：
           // 平移及缩放控件（左上角）、比例尺控件（左下角）
           map.addControl(new GLargeMapControl());
           map.addControl(new GScaleControl());
           map.addControl(new GOverviewMapControl(new GSize(220,150)));
           map.enableScrollWheelZoom();
           // 将视图移到烟台芝罘区      
           map.setCenter(new GLatLng(weidu,jingdu),zoom);
           //addmarker();
           //根据xml文件向页面加载标记
           function addmarker()
            {
                GDownloadUrl("../js/data.xml",function(data){    
                                                           var xml= GXml.parse(data);
                                                           if(xml)
                                                           { 
                                                               var markers = xml.documentElement.getElementsByTagName("marker");                                                 
                                                               for (var i = 0; i < markers.length; i++)                                                                                                                  
                                                               {                                                                   
                                                                   var icontype=markers[i].getAttribute("icontype"); 
                                                                   var projectid=markers[i].getAttribute("projectid");                                               
                                                                   var title1=markers[i].getAttribute("Title");                                                                                                              
                                                                   var point = new GLatLng(parseFloat(markers[i].getAttribute("Lat")),parseFloat(markers[i].getAttribute("Lng")));
                                                                   var baseIcon = new GIcon();
                                                                   baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
                                                                   baseIcon.iconSize = new GSize(20, 20);
                                                                   baseIcon.shadowSize = new GSize(37, 34);
                                                                   baseIcon.iconAnchor = new GPoint(9, 34);
                                                                   baseIcon.infoWindowAnchor = new GPoint(9, 2);
                                                                   baseIcon.infoShadowAnchor = new GPoint(18, 25);

                                                                   // 在给定的点上创建带编号的标注
                                                                   function createMarker(point, title1,projectid) 
                                                                   {
                                                                       var icon1 = new GIcon(baseIcon);
                                                                       //判断图标的类型(不同的项目状态显示不同的图标)
                                                                       switch(icontype)
                                                                       {
                                                                           case "201":            //未售
                                                                               icon1.image="../images/index.gif";
                                                                               break;
                                                                           case "202":            //预售
                                                                               icon1.image="../images/index.gif";                                                                       
                                                                               break;
                                                                           case "203":            //在售
                                                                               icon1.image="../images/index.gif";
                                                                               break;
                                                                           case "204":            //尾盘
                                                                               icon1.image="../images/index.gif";
                                                                               break;
                                                                           case "301":            //完工
                                                                               icon1.image="../images/index.gif";
                                                                               break;
                                                                           case "302":            //其他
                                                                               icon1.image="../images/index.gif";
                                                                               break;
                                                                           case "303":            //建设中
                                                                               icon1.image="../images/index.gif";
                                                                               break;
                                                                           case "304":            //撤销
                                                                               icon1.image="../images/index.gif";
                                                                               break;
                                                                           default:
                                                                               icon1.image="../images/index.gif";
                                                                               break;
                                                                       }                                                                      
                                                                       //var markeroptions={borderPadding: 50, maxZoom: 10, trackMarkers: true,title:title1,icon:icon1};
                                                                       //var marker=new GMarker(point,markeroptions); 
                                                                       opts = {
		                                                                            "icon": icon1,
		                                                                            "title":title1,
		                                                                            "clickable": true,
		                                                                            "draggable": false,
		                                                                            "labelText": title1,
		                                                                            "labelOffset": new GSize(-16, -16)
	                                                                            };
	                                                                   var marker=new LabeledMarker(point,opts);
                                                                       //事件绑定                                                      
                                                                       //GEvent.addListener(marker, "click", function(){marker.openInfoWindowHtml("<b>" + "<a href='http://www.sina.com'>"+title1+"</a>" + "</b>");});   //显示信息窗口
                                                                       //GEvent.addListener(marker,"mouseout",function(){marker.closeInfoWindow();});
                                                                       GEvent.addListener(marker,"click",function(){marker.openInfoWindowHtml("<iframe id='infowon' src='loupan.aspx?floorid="+projectid+"'></iframe>");});                                                                      
                                                                       return marker;
                                                                    }
                                                                    map.addOverlay(createMarker(point, title1,projectid));
                                                               }
                                                           }
                                                           else
                                                           {
                                                               alert("xml文件路径不正确,请检查!");
                                                           }
                                                       });
            }                                                     
       }      
   }
   


 
