如何在 Google Fusion Table 中的同一表格/图层上构建多个下拉选择器菜单?

发布于 2025-01-08 02:32:40 字数 494 浏览 3 评论 0原文

我在我的网站社区媒体数据库上创建了一系列 Google Fusion Table 地图 它允许用户打开和关闭多个层。对于每一层,我还构建了一个下拉选择菜单,允许查看者根据该选择器过滤显示的结果。

我现在需要为每一层创建多个下拉选择菜单。例如,在链接的地图中,我想让观众不仅可以通过管理类型查看接入电视提供商,还可以通过与地方选举相关的节目的承载以及许多其他领域来查看接入电视提供商。

我在 Googgle FT 上还是个新手,几乎不了解 JavaScript。我尝试复制和粘贴一些代码示例,但我相信我没有正确建立唯一变量。他们以某种方式结束了冲突,但都不起作用。

有人可以帮助我了解在单个 Google Fusion 表/地图图层上创建多个选择菜单的简单方法是什么吗?谢谢!

~ Rob McCausland,CommunitymediaDatabase.org

I've created a series of Google Fusion Table maps on my site, Community Media Database,
which allow the user to toggle on and off multiple layers. For each layer, I've also built ONE drop-down select menu, allowing the viewer to filter the displayed results based on that one selector.

I'm at a point now where I need to create more than one drop down select menu for each layer. For exapmle, in the linked map, I'd like to allow the viewer to view access TV providers by not only management type, but also by carriage of local election-related programs, and a number of other fields, as well.

I'm still fairly new at Googgle FT, and barely know my way around JavaScript. I've tried copying and pasting some examples of code, but I believe I'm not correctly establishing unique variables. They end of conflicting somehow, and none of them work.

Can someone help me learn what would be the simple approach to creating more than one select menu on a single Google Fusion Table/map layer? Thanks!

~ Rob McCausland, CommunitymediaDatabase.org

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一片旧的回忆 2025-01-15 02:32:40

问题一是能够从您的选择列表中检索值。我为所有选择列表提供一个 id,并使用 jQuery.js 来访问这些值:

var value = $('#program_select_id').val();

其次是通过“AND”链接您的查询条件,您的代码似乎已经掌握了这一点。

下面是我使用的一些 jQuery 相关代码的示例:

<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> 

<script type="text/javascript">

function setQuery(ft_layer, current_table_id, location_col)
{
    var query = [];

    var value = $('#program_select_id').val();
    if(value !== ''){
        query.push("'program' = '" +  value + "'");
    }
    value = $('#provider_select_id').val();
    if(value !== ''){
        query.push("'data_provider' = '" +  value + "'");
    }
    value = $('#observable_select_id').val();
    if(value !== ''){
        query.push("observables CONTAINS '" + value + "'");
    }

    var where = query.join(' AND ');

    var qryOpts = {
      query: {
        select: location_col,
        from: current_table_id,
        where: where
      }
    };
    ft_layer.setOptions(qryOpts);
}

</script>

Well issue one is being able to retrieve values from your select lists. I give all my select lists an id and use jQuery.js to access those values using:

var value = $('#program_select_id').val();

Second is chaining your query conditions via ' AND ' which your code already seems to grasp.

Here's an example of some jQuery dependent code that I use:

<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> 

<script type="text/javascript">

function setQuery(ft_layer, current_table_id, location_col)
{
    var query = [];

    var value = $('#program_select_id').val();
    if(value !== ''){
        query.push("'program' = '" +  value + "'");
    }
    value = $('#provider_select_id').val();
    if(value !== ''){
        query.push("'data_provider' = '" +  value + "'");
    }
    value = $('#observable_select_id').val();
    if(value !== ''){
        query.push("observables CONTAINS '" + value + "'");
    }

    var where = query.join(' AND ');

    var qryOpts = {
      query: {
        select: location_col,
        from: current_table_id,
        where: where
      }
    };
    ft_layer.setOptions(qryOpts);
}

</script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文