【问题标题】:load swf in jquery ui dialog在 jquery ui 对话框中加载 swf
【发布时间】:2011-07-08 10:10:11
【问题描述】:

我正在使用 fusionCharts 套件中的 fusionmap。我已经搜索了他们所有的文档和知识库以了解如何执行此操作,但没有运气,所以我正在与你们联系。

我有一个地图(swf 文件),它从 xml 文档中获取数据以构建其数据。在该 xml 中,对于特定实体,我可以进行 javascript 调用。在 swf 所在的文件中,我有我的 JS 和 jquery 库。我最终试图让另一个 swf 文件在 UI 对话框中弹出。如果可能的话,我不知道该怎么做。我弹出对话框,但它是空的。我希望在其中放置的 swf 文件加载在我的其他 swf 文件之上。有什么建议吗?

这是我的一些代码。

<script type="text/javascript"><!--
$(document).ready(function() { 
    $("#dialogContainer").dialog({
        bgiframe: true,
        height: 500,
        width: 600,
        modal: true,
        autoOpen: false,
        buttons: { "Close": function() { $(this).dialog("close"); }},
        show: 'fold',
        hide: 'fold'
    });
}); //Close ready function  


function loadDialog(continent) {
    //var url = 'showDetails.cfm?region=' + continent;
    //$("#dialogContainer").html('Loading. Please wait...');
    $.ajax({
        type: "post",
        url: 'showDetails.cfm',
        cache: false,
        //dataType: 'html',
        data: 'region=' + continent,
        beforeSend: function() {$('#dialogContainer').html('Loading. Please wait...').dialog('open');},
        success: function(msg) {$('#dialogContainer').html(msg);},
        error: function(msg) {$('#dialogContainer').html(msg);} 
    });
}

我的 fusionmap 调用

<script type="text/javascript">
var map = new FusionMaps("Maps/FCMap_World8.swf", "Map1Id", "500", "300", "0", "0");
map.setDataURL("WorldData2.xml");
map.render("mapdiv");     
</script>

我知道在这个问题上这是一个长镜头,但只是希望。感谢您的浏览以及您可能有的任何建议。

克里斯

【问题讨论】:

    标签: jquery flash jquery-ui-dialog fusioncharts


    【解决方案1】:

    我可以将在 jQuery 模态窗口(对话框)上呈现 FusionCharts 所需的资源和示例代码转发给您。

    PowerCharts code samples 文档中提出了 FusionCharts 相同功能(使用 LinkedCharts)的一个非常不同的实现。

    在 jQuery Dialog 中渲染 FusionCharts 所需的步骤

    第 1 步:创建 HTML 对话框容器

    在页面的任何位置,创建一个空白

    并为其指定一个唯一 ID。

    第 2 步:创建 jQuery Dialog 和 FusionCharts 对象

    页面加载时(jQuery 文档就绪)将之前创建的分区转换为 jQuery 对话框。


    第 3 步:创建函数以加载 FusionCharts

    现在,我们创建一个加载 FusionCharts 并打开对话框的 JavaScript 函数。

    现在,用户可以在需要时调用此loadChartInDialog 函数来打开对话框并加载图表。

    【讨论】:

      【解决方案2】:

      如果您使用 FusionCharts 3.2 之前的版本,您需要将图表的 wmode 设置为不透明或透明。

      这里有一个示例可以提供帮助:

      http://www.igcomm.com/show/maps/drill/jQuery

      这里使用了 3.1 FusionMaps 和 3.1.1 FusionCharts。截图如下:

      代码如下:

      <html>
        <head>
          <!-- Load FusionMaps 3.1 JavaScript wrapper -->
          <script language="JavaScript" src="FusionMaps.js"></script>
          <!-- Load FusionCharts 3.1.1 JavaScript wrapper -->
          <script language="JavaScript" src="FusionCharts.js"></script>
          <!-- Load jQuery UI resources to load jQuery dialog -->
          <link href="jquery.ui/jquery-ui.css" rel="stylesheet" type="text/css" />
          <script src="jquery.ui/jquery.min.js" type="text/javascript"></script>
          <script src="jquery.ui/jquery-ui.min.js" type="text/javascript"></script>
        </head>
        <body>
          <!-- Declare map and chart container DIVs -->
          <div id="mapdiv" align="center">FusionMaps will load here!</div>
          <div id="chartContainer" style="width:300px;height:300px;">FusionCharts will load here!</div>
      
          <script type="text/javascript"><!--
      
             // Declare jQuery dialog on the chart container
             var dialog;
             $(document).ready(function() {
                  dialog = $('#chartContainer').dialog({
                      autoOpen: false,
                      width: 340,
                      height: 370,
                  });
              });
      
             // Define and render map of World
             // In the XML data of the map each entity is linked to a JavaScript function showChart 
             // where respective entity id is passed
             var map = new FusionMaps("FCMap_World.swf", "Map1Id", "700", "450", "0", "0");
             // set map to opaque mode
             map.setTransparent(false);
             // If you wish you can set map to transparent mode uncommenting the line below
             //map.setTransparent(true);
             map.setDataURL("mapdata.xml");          
             map.render("mapdiv");
      
      
            // This function is called when a Map entity is clicked
            // It takes id as parameter where respective entity id is passed         
            function showChart(id)
            {
      
              // Stores the full name of each entity with resepct to the id
              var mapNames = {"NA" : "Noth America" , "SA" : "South America" , "AS" : "Asia" , "EU" : "Europe", "AF" : "Africa", "AU" : "Australia"};
      
              // Render chart
              var chart = new FusionMaps("Pie2D.swf", "chartId", "300", "300", "0", "0");
      
              // Set chart to opaque mode
              chart.setTransparent(false);
              // f you wish you can set chart to transparent mode uncommenting the line below
              //chart.setTransparent(true);
      
              // In this simple same detailed data for each map is stored in different files
              // The files are named as per the id
              chart.setDataURL(id+"Chart.xml");          
              chart.render("chartContainer");
      
              // Sets the dialog's title with the full name of the clicked entity
              dialog.dialog( "option", "title", 'Chart of ' + mapNames[id] );
              // Show the jQuery dialog which contains the chart
              dialog.dialog('open');
            }
          // -->   
          </script>
        </body>
      </html>
      

      也有源码下载:http://www.igcomm.com/show/maps/drill/jQuery/download.zip.

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-10-06
        • 1970-01-01
        • 1970-01-01
        • 2012-05-25
        相关资源
        最近更新 更多