www.pudn.com > GoogleEarth-information-systems.rar > map.php, change:2012-06-26,size:50061b


var ge = null; 
var gex = null; 
var Points = []; 
var bakupPoints = []; 
var extractTimes = 0; 
var polyParams = []; 
google.load('earth', '1'); 
function init() { 
    google.earth.createInstance('map3d', initCB, failureCB); 
} 
//地图加载成功调用 
function initCB(pluginInstance) { 
    ge = pluginInstance; 
    ge.getWindow().setVisibility(true); 
    setMapLayersStatus(true, true, true, true, true, true, false, false, false, false, false); 
	gex = new GEarthExtensions(pluginInstance); 
    window.external.JSInitSuccessCallback_(pluginInstance); 
} 
//地图加载失败调用 
function failureCB(errorCode) { 
    //alert(' sorry, the google earth load failed! please do it again...'); 
	window.external.JSInitFailureCallback_('Google Earth加载失败,可能是网络原因!'); 
} 
google.setOnLoadCallback(init); 
 
/* 
*地球赤道半径:6378.14 km 
*月球半径:1737.4 km 
*火星赤道半径:3397.2 km 
*/ 
function setMapMod(mod){ 
    switch(mod){ 
        case 'moon': 
			showMoon(); 
		    break; 
		case 'mars': 
			showMars(); 
		    break; 
		case 'sky': 
			//showSky(); 
		   // break; 
		default: 
			showEarth(); 
	} 
} 
 
var lastMapMod = 'earth'; 
function showEarth(){ 
	if(lastMapMod != 'earth'){ 
	    document.getElementById('map3d').innerHTML = ''; 
	    google.earth.createInstance('map3d', initCB, failureCB);          
	}else{ 
	    //ge.getOptions().setMapType(ge.MAP_TYPE_EARTH); 
	} 
	lastMapMod = 'earth'; 
} 
function showMoon(){ 
	if(lastMapMod != 'moon'){ 
	    document.getElementById('map3d').innerHTML = ''; 
	    google.earth.createInstance('map3d', initCB, failureCB, { database: 'http://khmdb.google.com/?db=moon' });  
	} 
	lastMapMod = 'moon'; 
} 
function showMars(){ 
	if(lastMapMod != 'mars'){ 
	    document.getElementById('map3d').innerHTML = ''; 
	    google.earth.createInstance('map3d', initCB, failureCB, { database: 'http://khmdb.google.com/?db=mars' });  
	} 
	lastMapMod = 'mars'; 
} 
function showSky(){ 
	if(lastMapMod != 'earth'){ 
	    document.getElementById('map3d').innerHTML = ''; 
	    google.earth.createInstance('map3d', initCB, failureCB);          
	} 
	ge.getOptions().setMapType(ge.MAP_TYPE_SKY); 
	lastMapMod = 'sky'; 
} 
/********************************************************************************************** 
* 
*以下程序开始 
* 
***********************************************************************************************/ 
//地图显示状态设置 //s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12 
function setMapLayersStatus(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11){ 
    ge.getOptions().setStatusBarVisibility(s1);  //显示经纬度、海拔状态栏 
    ge.getOptions().setScaleLegendVisibility(s2); //显示地图当前比例 
	if(lastMapMod == 'earth'){ 
        ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, s4);  //显示边界 
        ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, s3);  //显示道路 
		ge.getLayerRoot().enableLayerById(ge.LAYER_BUILDINGS, s11);  //显示三维建筑 
	} 
    ge.getLayerRoot().enableLayerById(ge.LAYER_TERRAIN, s6);  //显示三维地形 
    ge.getNavigationControl().setVisibility((s5 == true) ? ge.VISIBILITY_SHOW : ge.VISIBILITY_HIDE);  //显示导航控制工具 
	ge.getSun().setVisibility(s7);  //打开太阳 
	ge.getOptions().setAtmosphereVisibility(s8);  //打开大气层 
	ge.getOptions().setOverviewMapVisibility(s9);  //打开世界地图 
	ge.getOptions().setGridVisibility(s10);  //显示经纬网     
} 
 
var rubbishPoints = []; 
var figType = ''; 
function drawFigure(figuretype){ 
	//if(figType != 'point' ){  //&& figType != figuretype 
        chushihuaDrawFig(); 
	//} 
    figType = figuretype; 
	pathStyle = lineStyle; 
    doWhat = 0; 
    //removePointById('drawFigmark'); 
} 
 
//注册监听事件 
function addEventListenerDrawFig(){ 
	//chushihuaDrawFig(); 
	try{ 
        google.earth.addEventListener(ge.getGlobe(), 'mousedown', clickRightMouseDrawFig); 
	}catch(e){ 
	    alert("请等待加载地图!"); 
	} 
} 
 
//注销监听事件 
function removeEventListenerDrawFig(){ 
	if(figType != 'point'){ 
        chushihuaDrawFig(); 
	} 
    figType = ''; 
	try{ 
        google.earth.removeEventListener(ge.getGlobe(), 'mousedown', clickRightMouseDrawFig); 
		doWhat = 0; 
	}catch(e){ 
	    alert("请等待加载地图!"); 
	} 
} 
 
var doWhat = 0; 
function clickObjectDo(key){ 
    doWhat = key; 
    chushihuaDrawFig(); 
    //addEventListenerDrawFig(); 
} 
 
//识别对象-选择对象 
var objm = 0; 
function selectObjectToIdentify(key, m){ 
	bakupPoints = []; 
	if(m == 0 || m == 1){  //选择单个对象、任意地标 
		 //document.all.style.cursor = 'crosshair'; 
        clickObjectDo(key); 
        addEventListenerDrawFig(); 
		objm = m; 
	}else if(m == 2){  //所有地标 
        identifyAllPlacemark('KmlPoint'); 
		selectObjectInfos('地标', '点', bakupPoints.length, 0); 
        //window.external.autoIdentifyObjectsCallback_(pointName, pointType, isExtract, pointNum, 0); 
	}else{ 
 
	} 
} 
 
//设置画图监听事件 
//var pointPoints = []; 
var objPoints = []; 
var objectId = ''; 
var cases = { 
	'point': drawPointFunc, 
	'line': drawLineFunc, 
	'rectangle': drawRetangleFunc, 
	'polygon': drawPolygonFunc 
	//'circle': drawCircleFunc 
}; 
 
var clickRightMouseDrawFig = function(event){ 
 
 alert(figType); 
	if(event.getButton() == 2 && doWhat == 0){  //绘制对象 
		if (cases[figType]) { 
			cases[figType](event); 
		} 
	}else if(event.getButton() == 0 && doWhat == 1 && event.getTarget().getType() == 'KmlPlacemark'){  //选择删除对象 
        //chushihuaDrawFig(); 
        removeObject(event.getTarget()); 
		//objPoints = []; 
        doWhat = 0; 
        window.external.showDivMessageBox('', ''); 
	}else if(event.getButton() == 0 && doWhat == 2 && event.getTarget().getType() == 'KmlPlacemark'){  //选择编辑对象 
		editObject(event.getTarget()); 
		//chushihuaDrawFig(); 
		//objPoints = []; 
		//doWhat = 2; 
        //window.external.showDivMessageBox('', ''); 
	}else if(event.getButton() == 0 && doWhat == 3 && event.getTarget().getType() == 'KmlPlacemark'){  //测量对象 
        selectMeasureObject(event.getTarget()); 
	}else if(event.getButton() == 0 && doWhat == 4 && event.getTarget().getType() == 'KmlPlacemark'){  //设别对象 
        identifyObject(event.getTarget()); 
	} 
} 
 
function drawPointFunc(event){ 
    drawPoint(getUniqueId(), [event.getLatitude(), event.getLongitude(), 0], '地标', '经度:' + event.getLongitude().toFixed(6) + ',纬度:' + event.getLatitude().toFixed(6)); 
} 
 
function drawLineFunc(event){ 
	if(objectId == '') 
	{ 
		objectId = getUniqueId(); 
		drawPathCap(objectId, [event.getLatitude(), event.getLongitude(), 0], '路径', '这是路径'); 
	}else{ 
		addPathPoint(objectId, [event.getLatitude(), event.getLongitude(), 0]); 
	} 
} 
 
function drawRetangleFunc(event){ 
	if(objectId == '') 
	{ 
		objectId = getUniqueId(); 
		drawPoint(objectId, [event.getLatitude(), event.getLongitude(), 0], '矩形', '这是矩形'); 
		//drawPolygonCap(objectId, [event.getLatitude(), event.getLongitude(), 0], '矩形', '这是矩形'); 
		rubbishPoints.push(objectId); 
	}else{ 
        var obj = getObjectById(objectId); 
		var geometry = obj.getGeometry(); 
        var p0 = new geo.Point(geometry.getLatitude(), geometry.getLongitude(), geometry.getAltitude()); 
	    removeObject(obj); 
		rubbishPoints = []; 
		var p2 = new geo.Point(event.getLatitude(), event.getLongitude(), 0); 
		var p1 = getTrianglePoint(p0, p2); 
		var p3 = getTrianglePoint(p2, p0); 
		pathStyle = rectangleLineStyle; 
        drawRectangle(objectId+'rec', [[p0.lat(), p0.lng(), 0], [p1.lat(), p1.lng(), 0], [p2.lat(), p2.lng(), 0], [p3.lat(), p3.lng(), 0]], '矩形', '这是矩形'); 
		objectId = ''; 
	} 
} 
 
function drawPolygonFunc(event){ 
	if(objectId == '') 
	{ 
		objectId = getUniqueId(); 
		drawPoint(objectId, [event.getLatitude(), event.getLongitude(), 0], '多边形', '这是多边形'); 
		rubbishPoints.push(objectId); 
	}else{ 
		var obj = getObjectById(objectId); 
		var geometry = obj.getGeometry(); 
		if('KmlPoint' == geometry.getType()){ 
           // alert(geometry.getLatitude()); 
            objectId += 'poy'; 
			pathStyle = polygonLineStyle; 
		    drawPolygonCap(objectId, [[geometry.getLatitude(), geometry.getLongitude(), 0]], '多边形', '这是多边形'); 
	        removeObject(obj); 
			rubbishPoints = []; 
		} 
		addPolygonPoint(objectId, [event.getLatitude(), event.getLongitude(), 0]); 
	} 
} 
 
function drawCircleFunc(c, r, a1, a2, des, name){ 
	var n = 500; 
	var cs = c.split(','); 
    var cPoint = new geo.Point(parseFloat(cs[1]), parseFloat(cs[0])); 
	var r = parseFloat(r); 
	var a1 = parseFloat(a1); 
	var a2 = parseFloat(a2); 
	objPoints = []; 
    if(Math.abs(a2.sub(a1)) >= 360){  //画圆 
        for(var i = 0; i < n; i++){ 
           objPoints.push(getPointLocationByDHA(cPoint, r, (360/n)*i)); 
		} 
		pathStyle = circleLineStyle; 
		drawPolygon(getUniqueId(), objPoints, (name == '') ? '圆' : name, des); 
		objPoints = []; 
	}else{  //画扇形 
		objPoints.push(cPoint); 
		var ad = a2.sub(a1); 
		var adabs = Math.abs(ad); 
		n = adabs*n.div(360); 
        for(var i = 0; i < n; i++){ 
           objPoints.push(getPointLocationByDHA(cPoint, r, a1.add(ad/n*i))); 
		} 
		pathStyle = fanLineStyle; 
		drawPolygon(getUniqueId(), objPoints, (name == '') ? '扇形' : name, des); 
		objPoints = [];         
	} 
	removeEventListenerSetCircleParams(); 
    chushihuaDrawFig(); 
    //removeCirclePointmark(); 
} 
 
//预设值图形样式 
var pointStyle = { label: { scale: 1, color: 'White', opacity: 1}, icon: { stockIcon: 'pushpin/ylw-pushpin', color: 'White', opacity: 1, scale: 1.1 }}; 
var lineStyle = { line: { width: 3, opacity: 1, color: 'Red'}, icon: { stockIcon: 'paddle/red-circle'}};  //红色, stockIcon: 'paddle/red-circle' 
//lineStyle.line.getOpacity = function() {return 0.8} 
var rulerStyle = { line: { width: 6, opacity: 0.3, color: 'Red'}, icon: { stockIcon: 'paddle/blu-stars'}};  //红色 
//rulerStyle.getOpacity = function() {return 0.3} 
var rectangleLineStyle = { width: 3, opacity: 1, color: 'Blue'};  //蓝色 
var polygonLineStyle = { width: 3, opacity: 1, color: 'Yellow'};  //黄色 
var circleLineStyle = { width: 3, opacity: 1, color: 'Fuchsia'};  //粉色 
var fanLineStyle = { width: 3, opacity: 1, color: 'Lime'};  //绿色 
var pathStyle = lineStyle; 
 
 
function chushihuaDrawFig(){ 
	if(objectId != ''){ 
		var obj = getObjectById(objectId); 
		if('KmlPoint' == obj.getGeometry().getType()){ 
			//alert(geometry.getLatitude()); 
			for(var i = 0; i < rubbishPoints.length; i++){ 
				//alert(rubbishPoints[i]); 
				removeObject(getObjectById(rubbishPoints[i])); 
			} 
		}else if('KmlMultiGeometry' == obj.getGeometry().getType()){ 
			if(obj.getGeometry().getGeometries().getChildNodes().item(1).getCoordinates().getLength() == 1){ 
			    removeObject(obj); 
			}else{ 
			    drawPathRearCap(objectId); 
			} 
		}else if('KmlPolygon' == obj.getGeometry().getType() && obj.getGeometry().getOuterBoundary().getCoordinates().getLength() == 2){ 
			removeObject(obj); 
		} 
	} 
	rubbishPoints = []; 
	objectId = ''; 
} 
 
//删除倒数第n个对象 
function removeLastObj(n){ 
    var nodes = ge.getFeatures().getChildNodes(); 
	if(nodes.getLength() > 0){ 
        ge.getFeatures().removeChild(nodes.item(nodes.getLength()-n)); 
	} 
} 
 
function getLastObj(){ 
    var nodes = ge.getFeatures().getChildNodes(); 
    return nodes.item(nodes.getLength()-1); 
} 
 
//删除对象 
function removeObject(obj){ 
    gex.dom.removeObject(obj); 
} 
 
function removeThisObject(){ 
	getObjectType(); 
	//alert('qqqqq'); 
    //removeObject(obj); 
	if(objPoints.length > 0){ 
		//removeLastObj(1); 
		chushihuaDrawFig(); 
	} 
} 
 
//删除所有对象 
function clearAllObjs(){ 
    gex.dom.clearFeatures(); 
} 
 
//撤销上一步操作 
function cancelLineLastStep(){ 
	if(objectId != ''){ 
		var obj = getObjectById(objectId); 
		if('KmlMultiGeometry' == obj.getGeometry().getType()){ 
			var coordinates = obj.getGeometry().getGeometries().getChildNodes().item(1).getCoordinates(); 
            if(coordinates.getLength() > 1){ 
				coordinates.pop(); 
			}else{ 
				removeObject(obj); 
				objectId = ''; 
				rubbishPoints = []; 
			} 
		}else if('KmlPolygon' == obj.getGeometry().getType()){ 
            var coordinates = obj.getGeometry().getOuterBoundary().getCoordinates(); 
			if(coordinates.getLength() > 2){ 
                coordinates.pop(); 
			}else{ 
				removeObject(obj); 
				objectId = ''; 
				rubbishPoints = []; 
			} 
		} 
	} 
} 
 
//初始化测距 
function addEventListenerMeasureDistance(){ 
	//alert('aaaaaaaa'); 
    drawFigure('line'); 
	//chushihuaDrawFig(); 
	try{ 
	    google.earth.addEventListener(ge.getGlobe(), 'mousedown', clickRightMouseDrawFig); 
	    google.earth.addEventListener(ge.getGlobe(), 'mousedown', clickRightMouseMeasureDistance); 
	}catch(e){ 
	    alert("请等待加载地图!"); 
	} 
	pathStyle = rulerStyle; 
} 
 
//取消测距 
function removeEventListenerMeasureDistance(){ 
    figType = ''; 
	//objPoints = []; 
	chushihuaDrawFig(); 
    doWhat = 0; 
	try{ 
        google.earth.removeEventListener(ge.getGlobe(), 'mousedown', clickRightMouseDrawFig); 
        google.earth.removeEventListener(ge.getGlobe(), 'mousedown', clickRightMouseMeasureDistance); 
	}catch(e){ 
	    alert("请等待加载地图!"); 
	} 
	//pathStyle = lineStyle; 
} 
 
//返回到前一次测距 
function subMeasureDistance(){ 
    cancelLineLastStep(); 
	if(objectId != ''){ 
        goBackMeasureDistance(); 
	} 
} 
 
//设置测量距离监听函数 
var clickRightMouseMeasureDistance = function(event){ 
   // alert('up'); 
	if(event.getButton() == 2){ 
		//alert('aaaaaaaaaaaaaaa'); 
		//Points.push([event.getLatitude(), event.getLongitude(), event.getAltitude()]); 
		window.external.measureDistanceCallback_(computePathDistance(getObjectById(objectId))); 
	} 
} 
 
function goBackMeasureDistance(){ 
    window.external.measureDistanceCallback_(computePathDistance(getObjectById(objectId))); 
} 
 
//选择测量对象 
function selectMeasureObject(obj){ 
	//var d = 0; 
	//alert('ddddddddd'); 
 	switch(obj.getGeometry().getType()){ 
		case 'KmlMultiGeometry': 
		case 'KmlLineString':  //测距(长度) 
		    //alert("测距"); 
            window.external.measureObjectCallback_(0, 0, computePathDistance(obj)); 
            break; 
		case 'KmlLinearRing': 
		case 'KmlPolygon':  //测面积和周长 
		    //alert("测面积"); 
			var params = computeAreaAndC(obj); 
            window.external.measureObjectCallback_(params[0], params[1], 0); 
            break; 
		default: 
	}    
} 
 
function identifyAllPlacemark(KmlType){ 
	//bakupPoints = []; 
    gex.dom.walk({  
		rootObject: ge,  
		visitCallback: function() {  
		    if ('getType' in this && this.getType() == 'KmlPlacemark') {  
				if(this.getGeometry().getType() == KmlType){ 
			        //alert(this.getGeometry().getLatitude()); 
					bakupPoints.push({key: this.getName(), value: new geo.Point(this.getGeometry())}); 
				} 
		    }  
		}  
	}); 
} 
 
//自动识别对象,用于提取经纬度和高程 
function identifyObject(obj){ 
    //bakupPoints = []; 
	if(objm == 0){  //单个对象 
		bakupPoints = []; 
		switch(obj.getGeometry().getType()){ 
			case 'KmlPoint': 
				bakupPoints.push({key: obj.getName(), value: new geo.Point(obj.getGeometry())}); 
				selectObjectInfos(obj.getName(), '点', 1, 0); 
				break; 
			case 'KmlLineString': 
				//alert('KmlLineString'); 
				var coords = obj.getGeometry().getCoordinates(); 
				var length = coords.getLength(); 
				for(var i = 0; i < length; i++){ 
					bakupPoints.push(new geo.Point(coords.get(i))); 
				} 
				selectObjectInfos(obj.getName(), '线', 1, 1); 
				break; 
			case 'KmlPolygon': 
				var coords = obj.getGeometry().getOuterBoundary().getCoordinates(); 
				var length = coords.getLength(); 
				var lats = []; 
				var lngs = []; 
				for(var i = 0; i < length; i++){ 
					//alert(coords.get(i).getLatitude()); 
					lats.push(coords.get(i).getLatitude()); 
					lngs.push(coords.get(i).getLongitude()); 
				} 
				var latsMax = lats.max(); 
				var latsMin = lats.min(); 
				var lngsMax = lngs.max(); 
				var lngsMin = lngs.min(); 
				//alert(latsMax+','+latsMin+','+lngsMax+','+lngsMin); 
				bakupPoints = [createGeoPointByLatLngAlt(latsMax, lngsMin, 0), createGeoPointByLatLngAlt(latsMax, lngsMax, 0), createGeoPointByLatLngAlt(latsMin, lngsMax, 0), createGeoPointByLatLngAlt(latsMin, lngsMin, 0)]; 
				selectObjectInfos(obj.getName(), '面', 1, 2); 
				//drawRectangle(getUniqueId(), bakupPoints, 'box', 'aaaaaaaa'); 
				break; 
			case 'KmlMultiGeometry': 
				var geoms = obj.getGeometry().getGeometries();  
				if(geoms.getChildNodes().item(1).getType() == 'KmlLineString'){ 
                    var coords = geoms.getChildNodes().item(1).getCoordinates(); 
					var length = coords.getLength(); 
					for(var i = 0; i < length; i++){ 
						//alert(coords.get(i).getLatitude()); 
                        bakupPoints.push(new geo.Point(coords.get(i))); 
					} 
			    } 
				selectObjectInfos(obj.getName(), '线', 1, 1); 
				break; 
			default:  
				//alert('不能识别该对象!'); 
		} 
	}else if(objm == 1){  //任意点对象 
		if(obj.getGeometry().getType() == 'KmlPoint'){ 
		    bakupPoints.push({key: obj.getName(), value: new geo.Point(obj.getGeometry())}); 
		    selectObjectInfos(obj.getName(), '点', bakupPoints.length, 0); 
		}else{ 
            //alert('请选择点对象!'); 
		} 
	} 
} 
/* 
//获得对象信息 
function getObjectInfosToExtract(obj){ 
    var objInfos = new Object(); 
    objInfos.type = obj.getGeometry().getType(); 
	switch(objInfos.type){ 
		case 'KmlPoint': 
            bakupPoints.push({key: obj.getName(), value: new geo.Point(obj.getGeometry().getLatitude(), obj.getGeometry().getLongitude(), obj.getGeometry().getAltitude())}); 
			objInfos.name = obj.getName(); 
			objInfos.type = obj.getGeometry().getType() 
			break; 
		case 'KmlLineString': 
			break; 
		case 'KmlPolygon': 
			break; 
		case 'KmlMultiGeometry': 
			break; 
		default: return null; 
	} 
	//objInfos.coordinates = objInfos.type; 
    return objInfos; 
} 
*/ 
function selectObjectInfos(name, type, num, extractType){ 
	var isExtract = '否'; 
	if(num > 0){ 
		isExtract = '是'; 
	} 
	window.external.autoIdentifyObjectsCallback_(name, type, isExtract, num, extractType); 
} 
 
var activeTextBox = ''; 
function addEventListenerSetCircleParams(textBox){ 
	try{ 
	    google.earth.addEventListener(ge.getGlobe(), 'mousemove', moveMouseGetCoords); 
        google.earth.addEventListener(ge.getGlobe(), 'mousedown', clickRightMouseGetCoords); 
	}catch(e){ 
	    alert("请等待加载地图!"); 
	} 
    activeTextBox = textBox; 
} 
 
function removeEventListenerSetCircleParams(){ 
	try{ 
        google.earth.removeEventListener(ge.getGlobe(), 'mousemove', moveMouseGetCoords); 
        google.earth.removeEventListener(ge.getGlobe(), 'mousedown', clickRightMouseGetCoords); 
	}catch(e){ 
	    alert("请等待加载地图!"); 
	} 
	activeTextBox = ''; 
} 
 
//画圆参数设置,移动鼠标获取坐标监听函数 
var centerPointName = ''; 
var moveMouseGetCoords = function(event){ 
	var param = ''; 
	switch(activeTextBox){ 
        case 'textBox1': 
			centerPointName = '圆心'; 
		    param = event.getLongitude().toFixed(6) + ',' + event.getLatitude().toFixed(6); 
            break; 
		case 'textBox2': 
			centerPointName = '半径'; 
			var centerPoint = (window.external.getTextBoxValue('textBox1')).split(','); 
			if(centerPoint != ''){ 
		        param = getHorizontalDistance(new geo.Point(parseFloat(centerPoint[1]), parseFloat(centerPoint[0])), new geo.Point(event.getLatitude(), event.getLongitude())).toFixed(2); 
	        }else{ 
                activeTextBox = 'textBox6'; 
			} 
            break; 
		case 'textBox3': 
			centerPointName = '起始位置'; 
			var centerPoint = (window.external.getTextBoxValue('textBox1')).split(','); 
			if(centerPoint != ''){ 
		        param = new geo.Point(parseFloat(centerPoint[1]), parseFloat(centerPoint[0])).heading(new geo.Point(event.getLatitude(), event.getLongitude())).toFixed(2); 
	        }else{ 
                activeTextBox = 'textBox6'; 
			} 
			break; 
		case 'textBox4': 
			centerPointName = '结束位置'; 
			var centerPoint = (window.external.getTextBoxValue('textBox1')).split(','); 
			if(centerPoint != ''){ 
		        param = new geo.Point(parseFloat(centerPoint[1]), parseFloat(centerPoint[0])).heading(new geo.Point(event.getLatitude(), event.getLongitude())).toFixed(2); 
	        }else{ 
                activeTextBox = 'textBox6'; 
			} 
			break; 
        default: 
	} 
    window.external.inputTextBoxCoordsCallback_(activeTextBox, param); 
} 
 
//设置点击鼠标获取坐标监听函数 
var clickRightMouseGetCoords = function(event){ 
	if(event.getButton() == 2){ 
		removeEventListenerSetCircleParams(); 
        //removePointById(centerPointName); 
		objectId = getUniqueId(); 
        rubbishPoints.push(objectId); 
		drawPoint(objectId, [event.getLatitude(), event.getLongitude(), 0], centerPointName, '经度:' + event.getLongitude().toFixed(6) + ',纬度:' + event.getLatitude().toFixed(6)); 
       // alert(getPointByName(centerPointName).getName()); 
		//removeObject(getPointByName(centerPointName)); 
		//drawPointId(event.getLatitude(), event.getLongitude(), centerPointName, '经度:' + event.getLongitude().toFixed(6) + ',纬度:' + event.getLatitude().toFixed(6), centerPointName); 
		//window.external.inputTextBoxCoordsCallback_(event.getLatitude().toFixed(6) + ',' + event.getLongitude().toFixed(6)); 
    } 
} 
 
 
//var objStyle = {}; 
function dragPlacemark(){ 
    removeEventListenerDrawFig(); 
	if(eObj != null){ 
		gex.edit.makeDraggable(eObj, { 
		  bounce: false, 
		  dropCallback: function() { 
			//gex.edit.endDraggable(obj); 
		  }, 
		  draggingStyle: pointStyle 
		}); 
	} 
	doWhat = 2; 
} 
 
function endEditPlacemark(){ 
    gex.edit.endDraggable(eObj); 
    eObj = null; 
	addEventListenerDrawFig(); 
} 
 
function modifyPlacemark(name){ 
    eObj.setName(name); 
} 
 
//编辑对象 
var eObj = null; 
function editObject(obj){ 
	var id = ''; 
	var name = ''; 
	var des = ''; 
	if(obj.getGeometry().getType() == 'KmlPoint'){ 
		/* 
		if('getName' in obj){ 
			name = obj.getName()+'新的'; 
		} 
		if('getDescription' in obj){ 
			des = obj.getDescription()+'滴答滴答滴答滴答滴答滴答滴答滴答滴答';                         
		} 
		*/ 
        eObj = obj; 
        //dragPlacemark(obj); 
		window.external.editPointPlacemarkCallback_(obj.getName()); 
		/* 
		if('getId' in obj && obj.getId() == ''){ 
			removeObject(obj); 
			id = getUniqueId(); 
			var pointStyleUrl = ''; 
		    var point = []; 
			if('getStyleUrl' in obj && obj.getStyleUrl() != ''){ 
				pointStyleUrl = obj.getStyleUrl(); 
				var objGeometry = obj.getGeometry(); 
				point = [objGeometry.getLatitude(), objGeometry.getLongitude(), objGeometry.getAltitude()]; 
			} 
			obj = gex.dom.addPointPlacemark({id: id, name: name, point: point, description: des, style: pointStyleUrl}); 
			//obj = getObjectById(id); 
		}else{ 
            id = obj.getId(); 
 
		} 
		//if(obj.getStyleSelector() == null){ 
            alert(ge.getElementById('msn_ylw-pushpin').getKml()); 
		//} 
        //if('getStyleSelector' in obj && obj.getStyleSelector() != null){ 
            //if('getLabelStyle' in obj.getStyleSelector() && obj.getStyleSelector().getLabelStyle() != null){ 
				if('getColor' in obj.getStyleSelector().getLabelStyle() && obj.getStyleSelector().getLabelStyle().getColor() != null){ 
                    //pointStyle.label.color = obj.getStyleSelector().getLabelStyle().getColor().get(); 
                    pointStyle.label.color = 'Green'; 
				} 
				alert(pointStyle.label.color); 
			//} 
		//} 
		//alert(obj.getId()); 
 
			//alert(obj.getName()); 
			//alert(obj.getGeometry().getAltitude()+','+obj.getGeometry().getAltitudeMode()); 
			//if(obj.getGeometry().getAltitude() == ''){ 
				//alert('no alt'); 
               // obj.getGeometry().setAltitude(0); 
				//obj.getGeometry().setAltitudeMode(ge.ALTITUDE_RELATIVE_TO_GROUND); 
			//} 
			//alert(obj.getId()); 
			//alert(obj.getStyleSelector().getLabelStyle().getColor().get()); 
			//alert(obj.getId()+","+obj.getGeometry().getType()+','+obj.getStyleSelector().getType()+','+obj.getStyleSelector().getNormalStyle().getLabelStyle().getScale());//+','+ obj.getStyleSelector().getLabelStyle().getScale() 
			//alert(obj.getStyleSelector().getNormalStyle().getIconStyle().getScale()+','+obj.getStyleSelector().getNormalStyle().getIconStyle().getColor().get());  //如果加了hilightstyle属性,需用obj.getStyleSelector().getNormalStyle().getLabelStyle().getScale();否则用obj.getStyleSelector().getLabelStyle().getScale(); 
			//alert(obj.getGeometry().getAltitude()+','+obj.getGeometry().getAltitudeMode());   obj.getStyleSelector().getNormalStyle().getIconStyle().getStockIcon() 
			*/ 
			//window.external.editPointCallback_(obj.getId(), obj.getGeometry().getType(), obj.getName(), obj.getDescription(), obj.getStyleSelector().getLabelStyle().getColor().get(), obj.getStyleSelector().getLabelStyle().getScale(), obj.getStyleSelector().getIconStyle().getColor().get(), obj.getStyleSelector().getIconStyle().getScale(), obj.getGeometry().getAltitude(), obj.getGeometry().getAltitudeMode()); 
		}else if('getId' in obj && obj.getGeometry().getType() == 'KmlLineString'){ 
			//alert(obj.getOpacity()); 
			//alert(obj.getStyleSelector().getLineStyle().getColor().get()); 
			//window.external.editPathCallback_(obj.getId(), obj.getGeometry().getType(), obj.getName(), obj.getDescription(), obj.getStyleSelector().getLineStyle().getWidth(), obj.getStyleSelector().getLineStyle().getColor().get()); 
		}else if('getId' in obj && obj.getGeometry().getType() == 'KmlLinearRing'){ 
 
		}else if('getId' in obj && obj.getGeometry().getType() == 'KmlPolygon'){ 
			//alert(obj.getStyleSelector().getLineStyle().getColor().get()); 
			//window.external.editPolygonCallback_(obj.getId(), obj.getGeometry().getType(), obj.getName(), obj.getDescription(), obj.getStyleSelector().getLineStyle().getWidth(), obj.getStyleSelector().getLineStyle().getColor().get(), obj.getStyleSelector().getPolyStyle().getColor().get()); 
		}else if('getId' in obj && obj.getGeometry().getType() == 'KmlModel'){ 
 
		}else{ 
			//alert('no id'); 
		}//obj.getName() 
	   // window.external.openEditObjectPanelCallback_(obj.getGeometry().getType()); 
	//}else{ 
    //    obj.setId(getUniqueId()); 
	//} 
} 
 
function updatePoint(oid, labelName, description, labelColor, labelScale, labelOpacity, iconColor, iconScale, iconOpacity, systemIcon, ownIcon, altitude, altitudeMode){ 
    var obj = getObjectById(oid); 
	alert(labelName); 
	obj.setName(labelName); 
	obj.setDescription(description); 
	obj.getStyleSelector().getIconStyle().setScale(iconScale); 
	//obj.setLatLngAlt(obj.lat(), obj.lng(), iconAltitude); 
} 
 
function updateLine(oid, lineName, lineDescription, lineWidth, lineColor, lineOpacity){ 
    var obj = getObjectById(oid); 
	obj.setName(lineName); 
	obj.setDescription(lineDescription); 
	obj.getStyleSelector().getLineStyle().setWidth(lineWidth); 
	//alert(lineColor +","+lineOpacity); 
    obj.getStyleSelector().getLineStyle().getColor().set(mergeColorOpacity(lineColor, lineOpacity)); 
} 
 
function updatePolygon(oid, lineName, lineDescription, lineWidth, lineColor, lineOpacity, polyColor, polyOpacity){ 
    var obj = getObjectById(oid); 
	obj.setName(lineName); 
	obj.setDescription(lineDescription); 
	obj.getStyleSelector().getLineStyle().setWidth(lineWidth); 
    obj.getStyleSelector().getLineStyle().getColor().set(mergeColorOpacity(lineColor, lineOpacity)); 
	//alert(polyColor +","+polyOpacity +"|"+ lineColor+","+ lineOpacity); 
    obj.getStyleSelector().getPolyStyle().getColor().set(mergeColorOpacity(polyColor, polyOpacity));     
} 
 
function removePointById(id){ 
    gex.dom.walk({  
		rootObject: ge,  
		visitCallback: function() {  
		    if ('getType' in this && this.getType() == 'KmlPlacemark') {  
				if('getType' in this.getGeometry() && this.getGeometry().getType() == 'KmlPoint'){ 
                    if('getId' in this && this.getId() == id){ 
						removeObject(this); 
				    } 
				} 
		    }  
		}  
	});  
} 
 
function removePointByName(name){ 
    gex.dom.walk({  
		rootObject: ge,  
		visitCallback: function() {  
		    if ('getType' in this && this.getType() == 'KmlPlacemark') {  
				if('getType' in this.getGeometry() && this.getGeometry().getType() == 'KmlPoint'){ 
                    if('getName' in this && this.getName() == name){ 
						//alert(this.getName()); 
						removeObject(this); 
                        //return this; 
				    } 
				} 
		    }  
		}  
	});  
} 
/* 
//绘制点 
function drawPoint(lat, lng, name, description){ 
    gex.dom.addFolder([gex.dom.addPlacemark({ name: name, point: [lat, lng], description: description})]); 
} 
 
//绘制线 
function drawPath(objPoints, name, description){ 
    gex.dom.addFolder([gex.dom.buildLineStringPlacemark(objPoints, {name: name, description: description, style: { line: { width: 3, color: '#f00'}}})]); 
} 
*/ 
 
function getObjectType(){ 
    gex.dom.walk({  
		rootObject: ge,  
		visitCallback: function() {  
		    if ('getType' in this && this.getType() == 'KmlPlacemark') {  
				if(this.getGeometry().getType() == 'KmlPoint'){ 
			        alert(this.getName()); 
                    //removeObject(this); 
				}else if(this.getGeometry().getType() == 'KmlLineString'){ 
			        alert(this.getName()); 
                   // removeObject(this); 
				} 
		    }  
		}  
	});  
} 
 
 
function removeOldPoly(){ 
    var nodes = ge.getFeatures().getChildNodes(); 
	var nodeslength = nodes.getLength(); 
	for(var i = 2; i < nodeslength; i++){ 
        ge.getFeatures().removeChild(nodes.item(i)); 
    } 
} 
 
//清除所有自定义标记 
function clearAllObjects(){ 
	try{ 
		gex.dom.clearFeatures(); 
		bakupPoints = []; 
		Points = []; 
	//Lines = []; 
	}catch(err){} 
} 
 
//后退,撤销上一步操作 
function removeLastObject(num){ 
    var nodes = ge.getFeatures().getChildNodes(); 
	var nodeslength = nodes.getLength(); 
	if(nodeslength == 1){ 
        ge.getFeatures().removeChild(nodes.item(0)); 
	}else{ 
		for(var i = nodeslength - num; i < nodeslength && i >= 0; i++){ 
			ge.getFeatures().removeChild(nodes.item(i)); 
		} 
	} 
    bakupPoints.pop(); 
} 
 
function setOriginPoints(){ 
	cancelWebbrowserRun('run'); 
	Points = bakupPoints.slice(0); 
	pmCount = Points.length; 
	extractTimes = 0; 
	pPoints = []; 
	xNum = 0; 
	yNum = 0; 
} 
 
function setEarthState(point, flySpeed, range){ 
	if(flySpeed == 6){ 
        flySpeed = ge.SPEED_TELEPORT; 
	} 
    moveMapToPoint(point, range, flySpeed); 
} 
 
//计算地标高程点数 
function calPointsNum(){ 
	setOriginPoints(); 
	if(Points.length == 0){ 
		alert('请设置地标!'); 
        return; 
	} 
    window.external.calPointsOverCallback_(Points.length, ''); 
} 
 
//计算路线高程点数 
//参数说明:d:高程点间距;b:高程点加密倍数;f:高程差阈值 
function calLinesPointsNum(d){ 
	//d = parseFloat(d).mul(getStarRadius(lastMapMod)); 
	setOriginPoints(); 
	if(Points.length == 0){ 
		alert('请设置路线!'); 
        return; 
	} 
	try{ 
		//setTourObject(createTourKml(Points, 4, range)); 
		//playTour(); 
		var PACount; 
		var pCount = 1; 
		var HD = 0; 
		var D = 0; 
		//var iPoint = null; 
		var setPointsNum = Points.length; 
		for(var i = 1; i < setPointsNum; i++){ 
			//pCount++; 
			PACount = 0; 
			//HD = getHorizontalDistance(Points[i-1], Points[i]); 
			HD = getHorizontalDistance(Points[i-1], Points[i]); 
			D = parseFloat(D).add(parseFloat(HD)).toFixed(2); 
		   // pCount = Math.floor(parseFloat(D)/parseFloat(d)); 
			if(parseFloat(HD) > parseFloat(d)){ 
				PACount = Math.floor(parseFloat(HD).div(parseFloat(d))); 
				//if(parseInt(HD)%parseInt(d) <= 20){ 
				//    PACount--; 
				//} 
				/* 
				for(var j = 1; j < 100000000; j++){ 
					//iPoint = geo.math.destination(Points[i-1], {distance: d*j, heading: Points[i-1].heading(Points[i])}); 
					pCount++; 
					if(pCount%5000 == 0){ 
						if(pCount >= totalPointsNum){ 
							 window.external.calPointsErrorCallback_(); 
							 return false; 
						} 
						window.external.calPointsOKCallback_(pCount); 
					} 
				} 
				*/ 
			} 
			pCount = pCount + PACount +1; 
			window.external.calPointsOKCallback_(pCount, D); 
		} 
		//pCount++; 
		window.external.calPointsOverCallback_(pCount, D); 
	}catch(err){} 
} 
 
//计算面高程点数 
var pPoints = []; 
function calPolyPointsNum(d){ 
	//d = parseFloat(d).mul(getStarRadius(lastMapMod)); 
	setOriginPoints(); 
	if(Points.length == 0){ 
		alert('请设置对象!'); 
        return; 
	} 
	//alert(d); 
	//alert(pointsNum+','+ area); 
	try{ 
		var aPoly = getHorizontalDistance(Points[0], Points[1]).toFixed(2); 
		var bPoly = getHorizontalDistance(Points[0], Points[3]).toFixed(2); 
		//设定a为长边,b为短边 
		var temp = 0; 
		if(parseFloat(aPoly) < parseFloat(bPoly)){ 
			temp = bPoly; 
			bPoly = aPoly; 
			aPoly = temp; 
			Points = [Points[0], Points[3], Points[2], Points[1]]; 
			rotateMap(0); 
		}else{ 
			rotateMap(90); 
		} 
		var aNum = Math.ceil(parseFloat(aPoly).div(parseFloat(d))) + 1; 
		var bNum = Math.ceil(parseFloat(bPoly).div(parseFloat(d))) + 1; 
		var pointsNum = parseFloat(aNum).mul(parseFloat(bNum)); 
		var area = parseFloat(aPoly).mul(parseFloat(bPoly)); 
		polyParams = [Points[0], Points[0], aNum, bNum, aNum]; 
		//pPoints = []; 
		pPoints[0] = Points[0]; 
		//alert(pointsNum+','+ area); 
		window.external.calPointsOverCallback_(pointsNum, area); 
	}catch(err){} 
} 
 
//提取地标点高程-快速 
function extractPointsElevationsQuick(){ 
	var data = '['; 
    var placemarkCount = Points.length; 
	for(var i = 0; i < placemarkCount; i++){ 
        data += '{name:"' + Points[i].key + '",lat:"' + Points[i].value.lat().toFixed(6) +'",lng:"'+ Points[i].value.lng().toFixed(6) +'",alt:"'+ ge.getGlobe().getGroundAltitude(Points[i].value.lat(), Points[i].value.lng()).toFixed(2) +'"},'; 
	} 
	data += ']'; 
    window.external.extractElevationsCallback_(data, placemarkCount); 
    window.external.extractElevationsOKCallback_(placemarkCount); 
} 
 
//提取地标点高程-高精度and快速 
var pmCount = 0; 
function extractPointsElevationsHighQuick(){ 
	//alert(pCount); 
	if(pCount > 0){ 
	    //window.external.extractElevationsCallback_(data, pCount); 
	    sleep(1000); 
    } 
	if(pageStopRunFlag == true){ 
		pageStopRunFlag = false; 
		return; 
	} 
	if(Points.length > 0){ 
		if(pCount == 0){ 
            data = '['; 
		} 
		pCount++; 
		getSinglePointAltitude(Points[0]); 
		alert(Points.length); 
		//sleep(1000); 
	}else{ 
	    window.external.extractElevationsCallback_(']', pmCount); 
        window.external.extractElevationsOKCallback_(pmCount); 
	} 
} 
 
//提取地标高程-精确 
function extractPointsElevations(v, t){ 
	if(pageStopRunFlag == true){ 
		pageStopRunFlag = false; 
		return; 
	} 
	var range = 10; 
	if(pCount == 0){ 
        moveMapToPoint(Points[0].value, range, 6); 
        data = '['; 
		pCount++; 
        setTimeout('extractPointsElevations('+v+','+t+')', t); 
		return false; 
	} 
	data += '{name:"' + Points[0].key + '",lat:"'+Points[0].value.lat().toFixed(6)+'",lng:"'+Points[0].value.lng().toFixed(6)+'",alt:"'+ge.getGlobe().getGroundAltitude(Points[0].value.lat(), Points[0].value.lng()).toFixed(2)+'"},'; 
	if(Points.length > 0){ 
	    Points.splice(0, 1); 
	} 
    window.external.extractingElevationsCallback_(data, pCount); 
	data = ''; 
	if(Points.length > 0){ 
		moveMapToPoint(Points[0].value, range, 6); 
	    pCount++; 
		setTimeout('extractPointsElevations('+v+','+t+')', t);  //setInterval(func, time) 
		return false; 
	}else{ 
		window.external.extractElevationsCallback_(']', pCount); 
		window.external.extractElevationsOKCallback_(pCount); 
		pCount = 0; 
		data = ''; 
	} 
} 
/* 
function extractPointsElevations(v, t){ 
	//range = parseFloat(range).mul(getStarRadius(lastMapMod)); 
	var range = 500; 
	moveMapToPoint(Points[0].value, range, 6); 
	sleep(2000); 
	var data = '['; 
	pCount = 0; 
    var placemarkCount = Points.length; 
	for(var i = 0; i < placemarkCount; i++){ 
        moveMapToPoint(Points[i].value, range, v); 
		sleep(t); 
		pCount++; 
        data += '{name:"' + Points[i].key + '",lat:"' + Points[i].value.lat().toFixed(6) +'",lng:"'+ Points[i].value.lng().toFixed(6) +'",alt:"'+ ge.getGlobe().getGroundAltitude(Points[i].value.lat(), Points[i].value.lng()).toFixed(2) +'"},'; 
		window.external.extractingElevationsCallback_(data, pCount); 
		data = ''; 
		if(pageStopRunFlag == true){ 
			pageStopRunFlag = false; 
			return; 
		} 
	} 
	data += ']'; 
	window.external.extractElevationsCallback_(data, pCount); 
    window.external.extractElevationsOKCallback_(pCount); 
} 
*/ 
/******************************************************************************* 
*提取高程信息 
*参数说明:d:高程点间距;p:单次采样数目;v:地图视窗移动速度;t:地图加载时间 
*/ 
var data = ''; 
var pCount = 0; 
//var increaCount = 0; 
function extractLinesElevations(d, p, v, t){ 
    //d = parseFloat(d).mul(getStarRadius(lastMapMod)); 
	var range = 2*d*p + 20; 
	//alert(range); 
    moveMapToPoint(Points[0], range, 5); 
	//setTourObject(createTourKml(Points, Speed[flySpeed-1], 100)); 
    //playTour(); 
	//return; 
	data = '['; 
	pCount = 0; 
	//var range = 50; 
	//if(extractTimes == 0){ 
	   // setEarthState(Points[0], 3, range); 
		//sleep(2000); 
		//for(var i = 0; i < Points.length; i++){ 
	     //   moveMapToPoint(Points[i], 100, 1); 
		//	sleep(1000); 
			//alert(i); 
		//} 
	//} 
	setTimeout('extractPathElevation('+d+','+p+','+range+','+v+','+t+');', 2000); 
	//alert('aaaaaaaaaaaaaaa'); 
} 
 
function extractPathElevation(d, p, range, v, t){ 
	//d = parseFloat(d).mul(getStarRadius(lastMapMod)); 
	//range = parseFloat(range).mul(getStarRadius(lastMapMod)); 
	var PACount = 0; 
	var HD = 0; 
	var iPoint = null; 
	var movePoint = null; 
	var heading; 
    if(extractTimes == 0){ 
		pCount = 1; 
		extractTimes++; 
	    data += returnPointJson(Points[0]); 
	} 
	var setPointsNum = Points.length; 
    for(var i = 1; i < setPointsNum; i++){ 
		//return; 
		//pCount++; 
		//data += '{lat:"'+ Points[i-1].lat().toFixed(6) +'",lng:"'+ Points[i-1].lng().toFixed(6) +'",alt:"'+ ge.getGlobe().getGroundAltitude(Points[i-1].lat(), Points[i-1].lng()).toFixed(2) +''},'; 
		PACount = 0; 
        HD = getHorizontalDistance(Points[i-1], Points[i]); 
		//D = parseFloat(D) + parseFloat(HD); 
		if(parseFloat(HD) > parseFloat(d)){ 
			PACount = Math.floor(parseFloat(HD).div(parseFloat(d))); 
			//alert(PACount); 
			//if(parseInt(HD)%parseInt(d) <= 20){ //插入点和设置点距离小于等于10m时取消插入点 
			//    PACount--; 
			//} 
			//alert(PACount); 
			iPoint = Points[i-1]; 
            movePoint = getPointLocationByDHA(iPoint, d*p, iPoint.heading(Points[i])); 
			//drawPlacemarkByGeoPoint(movePoint, ge.getGlobe().getGroundAltitude(iPoint.lat(), iPoint.lng()).toFixed(2), 'PA'+pCount); 
			for(var j = p; j <= PACount+p; j=j+p){ 
				moveMapToPoint(movePoint, range, v); 
				sleep(t); 
				//drawPlacemarkByGeoPoint(iPoint, ge.getGlobe().getGroundAltitude(iPoint.lat(), iPoint.lng()).toFixed(2), 'PA'+pCount); 
				//heading = Points[i-1].heading(Points[i]); 
				for(var z = p; z >= 1 && j-z < PACount; z--){ 
					iPoint = getPointLocationByDHA(iPoint, d, iPoint.heading(Points[i])); 
					pCount++; 
					//drawPlacemarkByGeoPoint(iPoint, ge.getGlobe().getGroundAltitude(iPoint.lat(), iPoint.lng()).toFixed(2), 'PA'+pCount); 
					data += returnPointJson(iPoint); 
					if(pCount%10 == 0){ 
						//alert(pCount); 
						//if(pCount >= totalPointsNum){ 
						//     window.external.calPointsErrorCallback_(); 
						//	 return false; 
						//} 
						window.external.extractingElevationsCallback_(data, pCount); 
						if(pCount%65000 == 0){ 
							Points.splice(0, i, iPoint); 
							//window.external.extractingElevationsSaveCallback_(data+']', pCount); 
							window.external.extractElevationsCallback_(']', pCount); 
 
							//Points.splice(0, 0, ); 
							data = ''; 
							return false; 
							//data = '['; 
						} 
						data = ''; 
					} 
					if(pageStopRunFlag == true){ 
                        pageStopRunFlag = false; 
                        return; 
					} 
			    } 
				if(j+p > PACount){ 
			        movePoint = Points[i]; 
					if(j>PACount){ 
						iPoint = Points[i]; 
				    } 
				}else{ 
			        movePoint = getPointLocationByDHA(iPoint, d*(p+1), iPoint.heading(Points[i])); 
				} 
		    } 
				//iPoint = Points[i]; 
				 
				//alert(j); 
 
			//pCount++; 
		} 
		pCount++; 
		data += returnPointJson(Points[i]); 
		if(pCount%10 == 0){ 
			//increaCount = pCount; 
			window.external.extractingElevationsCallback_(data, pCount); 
			if(pCount%65000 == 0){ 
				Points.splice(0, i); 
				window.external.extractElevationsCallback_(']', pCount); 
				data = ''; 
				return false; 
			} 
			data = ''; 
		} 
		//pCount = pCount + PACount; 
        //window.external.calPointsOKCallback_(pCount, D); 
		//moveMapToPoint(Points[i], range, ge.SPEED_TELEPORT); 
		//sleep(1); 
		/* 
		alert(pCount); 
        pCount++; 
	    data += '{lat:"'+ Points[i].lat().toFixed(6) +'",lng:"'+ Points[i].lng().toFixed(6) +'",alt:"'+ ge.getGlobe().getGroundAltitude(Points[i].lat(), Points[i].lng()).toFixed(2) +''},'; 
		if(pCount%10 == 0){ 
			window.external.extractingElevationsCallback_(data, pCount); 
			if(pCount%70000 == 0){ 
				Points.splice(0, i); 
				window.external.extractElevationsCallback_(']', pCount); 
				data = ''; 
				return false; 
			} 
			data = ''; 
		} 
		*/ 
	} 
	data += ']'; 
    window.external.extractElevationsCallback_(data, pCount); 
    window.external.extractElevationsOKCallback_(pCount); 
	//moveMapToPoint(Points[0], 5000); 
} 
 
//快速提取线路高程 
function extractLinesElevationsQuick(d){ 
	//d = parseFloat(d).mul(getStarRadius(lastMapMod)); 
	var data = '['; 
	var PACount = 0; 
	pCount = 0; 
	var HD = 0; 
	//var D = 0; 
	var heading; 
	//var saveTimes = 0; 
	var iPoint = null; 
	if(extractTimes == 0){ 
		pCount = 1; 
		extractTimes++; 
        data += returnPointJson(Points[0]); 
	} 
	var setPointsNum = Points.length; 
    for(var i = 1; i < setPointsNum; i++){ 
		PACount = 0; 
        HD = getHorizontalDistance(Points[i-1], Points[i]); 
		//D = parseFloat(D).add(parseFloat(HD)); 
		if(parseFloat(HD) > parseFloat(d)){ 
	    	iPoint = Points[i-1]; 
	        PACount = Math.floor(parseInt(HD).div(parseInt(d))); 
            //heading = Points[i-1].heading(Points[i]); 
			for(var j = 1; j <= PACount; j++){ 
		        iPoint = getPointLocationByDHA(iPoint, d, iPoint.heading(Points[i])); 
				pCount++; 
				//drawPlacemarkByGeoPoint(iPoint, ge.getGlobe().getGroundAltitude(iPoint.lat(), iPoint.lng()).toFixed(2), 'PA'+pCount); 
				data += returnPointJson(iPoint); 
				if(pCount%2500 == 0){ 
                    window.external.extractingElevationsCallback_(data, pCount); 
					if(pCount%65000 == 0){ 
						Points.splice(0, i, iPoint); 
						window.external.extractElevationsCallback_(']', pCount); 
						data = ''; 
						return false; 
					} 
					data = ''; 
				} 
				if(pageStopRunFlag == true){ 
					pageStopRunFlag = false; 
					return; 
				} 
			} 
		} 
		pCount++; 
		data += returnPointJson(Points[i]); 
		if(pCount%2500 == 0){ 
			window.external.extractingElevationsCallback_(data, pCount); 
			if(pCount%65000 == 0){ 
				Points.splice(0, i); 
				window.external.extractElevationsCallback_(']', pCount); 
				data = ''; 
				//if(i >= setPointsNum-1){ 
	            //    window.external.extractElevationsOKCallback_(pCount); 
				//} 
				return false; 
			} 
			data = ''; 
		} 
	} 
	window.external.extractElevationsCallback_(data+']', pCount); 
	window.external.extractElevationsOKCallback_(pCount); 
} 
 
//提取多边形(矩形)区域高程 
var hheading; 
var vheading; 
function extractPolyElevations(d, p, v, t){ 
	//var range = d*(2*p-1) + 100; 
	//d = parseFloat(d).mul(getStarRadius(lastMapMod)); 
    var range = 2*d*p + 200; 
	if(extractTimes == 0){ 
		hheading = polyParams[0].heading(Points[1]); 
	    vheading = polyParams[0].heading(Points[3]); 
		getRectanglePoints(pPoints[0], d, p); 
		pPoints[4] = 0; 
		pPoints[5] = 0; 
        //extractTimes++; 
	} 
    moveMapToPoint(getPointLocationByDHA(pPoints[1], d*(p-1), vheading), range, 5); 
	//rotateMap(90); 
	//data = '['; 
	//pCount = 0; 
	setTimeout('extractPolyElevation('+d+','+p+','+range+','+v+','+t+');', 2000); 
} 
 
var qpoint = null; 
var hpoint = null; 
var qqpoint = null; 
var xNum = 0; 
var yNum = 0; 
function extractPolyElevation(d, p, range, v, t){ 
	//d = parseFloat(d).mul(getStarRadius(lastMapMod)); 
	//range = parseFloat(range).mul(getStarRadius(lastMapMod)); 
	var aNum = polyParams[2]; 
	var bNum = polyParams[3]; 
	//var xNum = ; 
    //var yNum = ; 
	//var vheading1 = vheading.sub(90); 
	//var vheading2 = vheading.add(90); 
	pCount = 0; 
	//increaCount = 0; 
	var xpoint = null; 
	var ypoint = null; 
	var mpoint = null; 
	var point = null; 
	var data = '['; 
	//mpoint = geo.math.destination(pPoints[1], {distance: d*(p-1), heading: vheading}); 
    //moveMapToPoint(mpoint, range, 5); 
    for(var i = yNum; i < bNum; i=i+2*p-1){ 
		for (var j = xNum; j < aNum; j=j+p) 
		{ 
			if(j == 0){ 
                qpoint = pPoints[3]; 
			} 
			ypoint = pPoints[0]; 
			for(var y = pPoints[4]; y <= 2*(p-1); y++){ 
				if(i+y+1 > bNum){ 
					//alert((j+y+1)+','+bNum); 
                    break; 
		        } 
				xpoint = getPointLocationByDHA(ypoint, d*y, vheading); 
				for(var x = pPoints[5]; x < p; x++){ 
					if(j+x+1 > aNum){ 
						//alert((i+x+1)+','+aNum); 
                        break; 
					} 
                    point = getPointLocationByDHA(xpoint, d*x, hheading); 
					pCount++; 
					data += returnPointJson(point); 
					//drawPlacemarkByGeoPoint(point, ge.getGlobe().getGroundAltitude(point.lat(), point.lng()).toFixed(2), 'PA'+pCount); 
					if(pCount%100 == 0){ 
						//increaCount = pCount; 
						window.external.extractingElevationsCallback_(data, pCount); 
						if(pCount%65000 == 0){ 
							yNum = i; 
							xNum = j; 
                            pPoints[4] = y; 
							pPoints[5] = x + 1; 
							extractTimes++; 
							window.external.extractElevationsCallback_(']', pCount); 
							data = ''; 
							return false; 
						} 
						data = ''; 
					} 
					if(pageStopRunFlag == true){ 
					    pageStopRunFlag = false; 
                        return; 
					} 
				} 
				pPoints[5] = 0; 
			} 
			pPoints[4] = 0; 
			xNum = 0; 
            getRectanglePoints(pPoints[1], d, p);  //得到矩形区域四角坐标 
			mpoint = getPointLocationByDHA(pPoints[1], d*(p-1), vheading); 
		    moveMapToPoint(mpoint, range, 5); 
			sleep(t); 
			//alert('ss'); 
		} 
		getRectanglePoints(getPointLocationByDHA(qpoint, d, vheading), d, p);  //得到矩形区域四角坐标 
		mpoint =getPointLocationByDHA(pPoints[1], d*(p-1), vheading); 
		moveMapToPoint(mpoint, range, 5); 
		sleep(t); 
	} 
	yNum = 0; 
    moveMapToPoint(polyParams[0], d*aNum, 5); 
	window.external.extractElevationsCallback_(data+']', pCount); 
	window.external.extractElevationsOKCallback_(pCount); 
} 
 
//快速提取多边形区域高程 
function extractPolyElevationsQuick(d){ 
    //alert(aPoly+','+bPoly+','+d); 
	//d = parseFloat(d).mul(getStarRadius(lastMapMod)); 
	var pCount = 0; 
	var pjCount; 
	var data = '['; 
	var jPoint = null; 
	var iPoint = null; 
	var aNum = polyParams[2]; 
	var bNum = polyParams[3]; 
	iPoint = polyParams[0]; 
	//var jjPoint = polyParams[1]; 
	//pCount++; 
	//data += '{lat:"'+ iPoint.lat().toFixed(6) +'",lng:"'+ iPoint.lng().toFixed(6) +'",alt:"'+ ge.getGlobe().getGroundAltitude(iPoint.lat(), iPoint.lng()).toFixed(2) +''},'; 
	for(var i = 1; i <= bNum; i++){ 
		for (var j = 1; j <= aNum; j++) 
		{ 
			if(j == 1){ 
				if(extractTimes == 0){ 
                    jPoint = iPoint; 
				}else{ 
                    jPoint = polyParams[1]; 
                    extractTimes = 0; 
				} 
			}else{ 
                jPoint = getPointLocationByDHA(jPoint, d, jPoint.heading(Points[1])); 
			} 
			pCount++; 
			data += returnPointJson(jPoint); 
			//drawPlacemarkByGeoPoint(jPoint, ge.getGlobe().getGroundAltitude(jPoint.lat(), jPoint.lng()).toFixed(2), 'PA'+pCount); 
			if(pCount%2500 == 0){ 
				window.external.extractingElevationsCallback_(data, pCount); 
				if(pCount%65000 == 0){ 
					//jPoint = geo.math.destination(iPoint, {distance: d, heading: iPoint.heading(Points[3])}); 
					//Points.splice(0, i); 
					polyParams[0] = iPoint; 
					if(j == aNum){ 
                        polyParams[1] = getPointLocationByDHA(iPoint, d, iPoint.heading(Points[3])); 
					}else{ 
					    polyParams[1] = getPointLocationByDHA(jPoint, d, jPoint.heading(Points[1])); 
					} 
					polyParams[3] = bNum -i + 1; 
                    polyParams[2] = aNum -j; 
					extractTimes++; 
					//if(i >= setPointsNum-1){ 
					//    window.external.extractElevationsOKCallback_(pCount); 
					//} 
					window.external.extractElevationsCallback_(']', pCount); 
					data = ''; 
					return false; 
				} 
				data = ''; 
			} 
			if(pageStopRunFlag == true){ 
				pageStopRunFlag = false; 
				return; 
			} 
		} 
		aNum = polyParams[4]; 
		iPoint = getPointLocationByDHA(iPoint, d, iPoint.heading(Points[3])); 
		Points[1] = getPointLocationByDHA(Points[1], d, Points[1].heading(Points[2])); 
	} 
	window.external.extractElevationsCallback_(data+']', pCount); 
	window.external.extractElevationsOKCallback_(pCount); 
}