Mapabc通过鼠标画点线面,取得各元素坐标。

 
private function tbb_itemClickHandler(event:ItemClickEvent):void
			{
				if (_HuiZhiGongJuUI.tbb.selectedIndex < 0)
				{
					//this.mapObj.();
				}
				else
				{
					//mapObj.addEventListener(MMapMouseEvent.MOUSE_CLICK,mouseClickCallback); //鼠标画点
					//mapObj.addEventListener(MMapMouseEvent.MOUSE_DBCLICK,mousedbClickCallback); //鼠标画点
				
						
					
					switch (event.item.label)
					{
						case "绘点":
							Types="P";
					mapObj.addEventListener(MMapEvent.ADD_OVERLAY ,mouseClickCallback); //鼠标画点
							mapObj.setCurrentMouseTool(MMapMouseTools.ADD_MARKER); 
									break;
						case "绘线":
							Types="L";
					mapObj.addEventListener(MMapEvent.ADD_OVERLAY,mouseClickCallback); //鼠标画线
							mapObj.setCurrentMouseTool(MMapMouseTools.DRAW_LINE);
																				break;
						case "绘面":
							Types="M";
					mapObj.addEventListener(MMapEvent.ADD_OVERLAY,mouseClickCallback); //鼠标画面
							mapObj.setCurrentMouseTool(MMapMouseTools.DRAW_POLYGON);
														break;
					}
				}
			}
			
			function mouseClickCallback(evt:MMapEvent):void {  
				if(Types=="P")
				{
					
					try{
						var marker:MMarker=mapObj.getOverlayById(evt.overlayId) as MMarker;
			                            zubiaomodeP.x=marker.lnglat.lngX.toString();
						zubiaomodeP.y=marker.lnglat.latY.toString();
												}
					
										
				}
				if(Types=="L")
				{
					var line:MPolyline=mapObj.getOverlayById(evt.overlayId) as MPolyline;
                                              zubiaomodeL.x=mlnL.lngX.toString();
                                              zubiaomodeL.y=mlnL.latY.toString();//
										}
					
								}
				if(Types=="M")
				{
					  var polygon:MPolygon=mapObj.getOverlayById(evt.overlayId) as MPolygon;
                                                 zubiaomodeM.x=mlnM.lngX.toString();
                                                zubiaomodeM.y=mlnM.latY.toString();//
										}
					
				mapObj.setCurrentMouseTool(MMapMouseTools.PAN_WHEELZOOM);		
							
			}

你可能感兴趣的:(map)