    function 高德地图(name,dianji,move,zoom,finish,event1,event2,event3,event4,event5,event6){   
      
        this.名称 = name;
		this.高度 = "200px";
		this.语言 = "zh_cn";
		this.样式 = "normal";
		this.城市 = "重庆市";
		this.缩放 = 11;
		this.横标 = 116.397428;
		this.纵标 = 39.90923;

		var map;
		var markers = [];
		var geolocation;
		
		this.初始化 = function (key){
			yrcss("http://cache.amap.com/lbs/static/main1119.css");
			//yrcss("css/amap_lbs.css");//css资源里的样式会自动引入
			yrjs("http://cache.amap.com/lbs/static/es5.min.js");
			if(key!=null && key!=""){
				yrjs("http://webapi.amap.com/maps?v=1.4.11&key="+key);
				yrjs("https://webapi.amap.com/maps?v=1.4.11&key="+key+"&plugin=AMap.Autocomplete,AMap.PlaceSearch,AMap.Driving");
			}else{
				alert("请在高德地图的初始化命令里输入您的key");
			}
			yrjs("http://cache.amap.com/lbs/static/addToolbar.js");
        }   
		
        this.显示地图 = function () {
			document.getElementById(this.名称).style.height=this.高度;
			map = new AMap.Map(this.名称, {
        		resizeEnable: true,
        		zoom: this.缩放,
        		center: [this.横标,this.纵标]
    		});
			
			if(dianji!=null) {
		     map.on("click", function(e) {
           		dianji(e.lnglat.getLng(),e.lnglat.getLat())
			});
           }
		   
		   if(move!=null) {
		     map.on("moveend", function(e) {
			 	var center=map.getCenter();
                move(center.lng,center.lat);
			});
           }
		   
		   if(zoom!=null) {
		     map.on("zoomend", function(e) {
			 	var zoomlevel=map.getZoom();
           		zoom(zoomlevel);
			});
           }
		   
		   if(finish!=null) {
		     map.on("complete", function() {
			 	var center=map.getCenter();
             	finish(center.lng,center.lat);	
			});
           }

			if(this.城市){
			   map.setCity(this.城市);
			}
			
			map.setLang(this.语言);
			map.setMapStyle("amap://styles/"+this.样式);

			// 同时引入工具条插件，比例尺插件和鹰眼插件
			AMap.plugin([
    			"AMap.ToolBar",
    			"AMap.Scale",
    			"AMap.OverView",
    			"AMap.MapType",
    			"AMap.Geolocation",
			], function(){
    			// 在图面添加工具条控件，工具条控件集成了缩放、平移、定位等功能按钮在内的组合控件
    			map.addControl(new AMap.ToolBar());

    			// 在图面添加比例尺控件，展示地图在当前层级和纬度下的比例尺
    			map.addControl(new AMap.Scale());

    			// 在图面添加鹰眼控件，在地图右下角显示地图的缩略图
    			map.addControl(new AMap.OverView({isOpen:true}));
   
    			// 在图面添加类别切换控件，实现默认图层与卫星图、实施交通图层之间切换的控制
    			map.addControl(new AMap.MapType());
   
    			// 在图面添加定位控件，用来获取和展示用户主机所在的经纬度位置
				geolocation = new AMap.Geolocation();
    			map.addControl(geolocation);
        		geolocation.getCurrentPosition(function(status,result){
					//console.log(status);
					//console.log(result);
            		if(status=="complete" && result.info=="SUCCESS"){
                		if(event1!=null){
							event1(result.position.lng, result.position.lat, result.formattedAddress, result.addressComponent, result.message);//定位成功
						}
            		}else{
                		if(event2!=null){
							event2(result.message);//定位失败
						}
            		}
        		});			
			});
		
        }

		this.获取定位 = function() {
			geolocation.getCurrentPosition(function(status,result){
            	if(status=="complete" && result.info=="SUCCESS"){
                	if(event1!=null){
						event1(result.position.lng, result.position.lat, result.formattedAddress, result.addressComponent, result.message);//定位成功
					}
            	}else{
                	if(event2!=null){
						event2(result.message);//定位失败
					}
            	}
        	});		
		}
		
		this.绑定搜索编辑框= function(inputID,cityName) {
			var autoOptions;
			if(cityName!=null && cityName!="" && cityName!="全国"){
		    	autoOptions={
					city: cityName,
					citylimit: true,
					input: inputID
				};
			}else{
		    	autoOptions={
					input: inputID
				};				
			}	       
			var auto = new AMap.Autocomplete(autoOptions);//绑定搜索编辑框
    		var placeSearch = new AMap.PlaceSearch({
         		map: map
       		});  //构造地点查询类
         	AMap.event.addListener(auto, "select", select);//注册监听，当选中某条记录时会触发
    		function select(e) {
				if(cityName!=null && cityName!="" && cityName!="全国"){
        			placeSearch.setCity(cityName);
					placeSearch.setCityLimit(true);
				}
        		placeSearch.search(e.poi.name,function (status, result) {//关键字查询
                	if(status=="complete" && result.info=="OK"){
						if(event5!=null){
							event5(true);//搜索成功
						}
					}else{
						if(event5!=null){
							event5(false);//搜索失败
						}					
					}					
				});  
    		}
			AMap.event.addListener(placeSearch, "markerClick", select_marker);	
			function select_marker(e){
				//console.log(e);
				if(event6!=null){
					event6(e.data.pname, e.data.cityname, e.data.adname, e.data.address, e.data.name, e.data.location.lng, e.data.location.lat);
				}
			}  
   		}
		
		this.置缩放等级及中心 = function(zoom,lng,lat) {
		    map.setZoomAndCenter(zoom,[lng,lat]);
		}
		
		this.添加标记 = function (hzb,zzb) {
			var marker = new AMap.Marker({
				map: map,
		    	position: new AMap.LngLat(hzb,zzb)
			});
			markers.push(marker);
		}

		this.添加标记_自定义 = function (hzb,zzb,markericon,w,h) {
			var icons = new AMap.Icon({
    			size: new AMap.Size(w, h),
    			image: markericon, 
    			imageSize: new AMap.Size(w, h)  
			});			
			var marker = new AMap.Marker({
				map: map,
		    	position: new AMap.LngLat(hzb,zzb),
				icon: icons
			});
			markers.push(marker);				
		}

		this.取标记数量 = function () {
			return markers.length;
		}
		
		this.清除标记 = function(i) {
			if(markers.length>i){
		  		markers[i].setMap(null);
				markers.splice(i,1);
			}
		}

		this.清除全部标记 = function() {
			for (var i = 0; i < markers.length; i++) {
		  		markers[i].setMap(null);
			}
			markers = [];
			map.clearMap();
		}
		
		this.显示导航路线_坐标 = function(startlng,startlat,endlng,endlat,detail) {
			//构造路线导航类
			var driving;
			if(detail==true){
       			driving = new AMap.Driving({
        			map: map,
					panel: "panel"
    			}); 				
			}else{
       			driving = new AMap.Driving({
        			map: map
    			}); 			
			}
    		// 根据起终点经纬度规划驾车导航路线
    		driving.search(new AMap.LngLat(startlng, startlat), new AMap.LngLat(endlng, endlat), function(status, result) {
        		// result 即是对应的驾车导航信息，相关数据结构文档请参考  https://lbs.amap.com/api/javascript-api/reference/route-search#m_DrivingResult
        		if (status === "complete") {
            		//console.log("绘制驾车路线完成")
					if(event3!=null){
						event3(result.origin.lng, result.origin.lat, result.destination.lng, result.destination.lat);
					}
        		} else {
            		//console.log("获取驾车数据失败：" + result)
					if(event4!=null){
						event4(result);
					}					
        		}
    		});
		}

		this.显示导航路线_名称 = function(起点名称,起点城市,终点名称,终点城市,detail) {
			//构造路线导航类
			var driving;
			if(detail==true){
       			driving = new AMap.Driving({
        			map: map,
					panel: "panel"
    			}); 				
			}else{
       			driving = new AMap.Driving({
        			map: map
    			}); 			
			}
    		// 根据起终点经纬度规划驾车导航路线
    		driving.search([{keyword:起点名称,city:起点城市},{keyword:终点名称,city:终点城市}], function(status, result) {
        		// result 即是对应的驾车导航信息，相关数据结构文档请参考  https://lbs.amap.com/api/javascript-api/reference/route-search#m_DrivingResult
        		if (status === "complete") {
            		//console.log("绘制驾车路线完成")
					if(event3!=null){				
						event3(result.origin.lng, result.origin.lat, result.destination.lng, result.destination.lat);
					}
        		} else {
            		//console.log("获取驾车数据失败：" + result)
					if(event4!=null){
						event4(result);
					}					
        		}
    		});
		}
		
		this.打开高德地图APP进行导航 = function (起点名称,起点经度,起点纬度,终点名称,终点经度,终点纬度){
			var driving = new AMap.Driving({
        		map: map
    		});
			var myorigin = new AMap.LngLat(起点经度,起点纬度);
			var mydestination = new AMap.LngLat(终点经度,终点纬度);
            driving.searchOnAMAP({
                origin:myorigin,
				originName:起点名称,
                destination:mydestination,
				destinationName:终点名称
           });
		}
		
		this.置高度 = function (canA){
			document.getElementById(this.名称).style.height = canA;
			this.高度 = canA;
        }
		
		this.置语言 = function (canA){
			if(canA){
				if(canA==1){
					this.语言 = "zh_en";
				}
				if(canA==2){
					this.语言 = "en";
				}
			}else{
				this.语言 = "zh_cn";
			}
        }
		
		this.自定义样式 = function (canA){
			this.样式 = canA;
        }
		
		this.置城市名 = function (canA){
			this.城市 = canA;
        }
		
		this.置缩放 = function (canA){
			this.缩放 = canA;
        }
		
		this.置中心点 = function (canA,canB){
			this.城市 = "";
			this.横标 = canA;
			this.纵标 = canB;
        }
		
		this.置样式 = function (canA){
			if(canA){
				if(canA==1){
					this.样式 = "darkblue";
				}
				if(canA==2){
					this.样式 = "blue";
				}
				if(canA==3){
					this.样式 = "fresh";
				}
				if(canA==4){
					this.样式 = "dark";
				}
				if(canA==5){
					this.样式 = "light";
				}
				if(canA==6){
					this.样式 = "grey";
				}
			}else{
				this.样式 = "normal";
			}
        }
		
		
        //组件命令：
        this.置可视 = function (value){
            if(value==true){
                var div = document.getElementById(this.名称).parentNode;
                div.style.display="block";//显示	                
            }else{
                var div = document.getElementById(this.名称).parentNode;
                div.style.display="none"; //不占位隐藏               
            }
        } 
        
        //组件命令：
        this.置可视2 = function (value){
            if(value==true){
                var div = document.getElementById(this.名称).parentNode;
                div.style.visibility="visible";//显示	                
            }else{
                var div = document.getElementById(this.名称).parentNode;
                div.style.visibility="hidden"; //占位隐藏               
            }
        } 
        
    }
	
	function yrjs(jsd){//引入js
		var JS = document.createElement("script");
		JS.type = "text/javascript";
		JS.src = jsd;
		document.getElementsByTagName("head").item(0).appendChild(JS);
	}
	
	function yrcss(jsd){//引入css
		var CSS = document.createElement("link");
		CSS.rel = "stylesheet";
		CSS.type = "text/css";
		CSS.href = jsd;
		document.getElementsByTagName("head").item(0).appendChild(CSS);
	}