// 添加右键
private function AddRightKeyMenu( ) : void {
var rightMenu : ContextMenu = new ContextMenu( );
var keyPointMenu : ContextMenuItem = new ContextMenuItem( "获取当前经纬度" );
keyPointMenu.addEventListener( ContextMenuEvent.MENU_ITEM_SELECT, OnGetPointPos );
rightMenu.customItems.push( keyPointMenu );
rightMenu.hideBuiltInItems();
map.contextMenu = rightMenu;
}
private function OnGetPointPos( event : ContextMenuEvent ) : void {
var mapPoint : MapPoint = this.map.toMapFromStage( event.mouseTarget.mouseX, event.mouseTarget.mouseY );
if (mapPoint != null){
var mapXY : String = mapPoint.x.toFixed(8) + ", " + mapPoint.y.toFixed(8);
System.setClipboard( mapXY );
}
}
Flex 添加右键菜单
最新推荐文章于 2017-06-14 22:32:41 发布