【问题标题】:One FusionTableLayer appears to be competing with another一个 FusionTableLayer 似乎正在与另一个竞争
【发布时间】:2013-07-23 02:38:37
【问题描述】:

我有一个带有两个融合表层的 Google 地图,一个带有标记,一个带有多边形。如果我显示没有样式的两个图层,它们就会显示出来。如果我设置标记的样式,它们都会出现。但是,当我尝试设置多边形样式时,标记不会出现。我没有想法。

// Initialize the first layer
    var firstLayer = new google.maps.FusionTablesLayer({
        query: {
            select: "'geometry'",
            from: '1eiyhdpl-5xnO7-csWgdrxxYHgFWRLjN0JADIX9o'
        },
        styles: [{
            where: "'ABORTIONS' < 100",
            polygonOptions: {
                fillColor: '#cc0000',
                fillOpacity: 0.2
            }
        },{
            where: "'ABORTIONS' > 100 AND 'ABORTIONS' < 1000",
            polygonOptions: {
                fillColor: '#cc0000',
                fillOpacity: 0.4
            }
        },{
            where: "'ABORTIONS' > 1000 AND 'ABORTIONS' < 10000",
            polygonOptions: {
                fillColor: '#cc0000',
                fillOpacity: 0.6
            }
        },{
            where: "'ABORTIONS' > 10000 AND 'ABORTIONS' < 100000",
            polygonOptions: {
                fillColor: '#cc0000',
                fillOpacity: 0.8
            }
        }],
        map: map,
        suppressInfoWindows: true
    });

    // Initialize the second layer
        var secondLayer = new google.maps.FusionTablesLayer({
        query: {
        select: "'address'",
            from: '1j7ogamqx3pXfiG0Eh1Ah0givle_thZE-OBgvQho'
        },
        styles: [{ 
        where: "rank = 1",
            markerOptions: {
            iconName: 'small_green'
           }
        },{ 
            where: "rank = 0",
                markerOptions: {
                    iconName: 'small_blue'
                }
        }],  
        map: map,
        suppressInfoWindows: true
    });

如果我删除或注释第一层的样式,第二层的样式标记就在那里。它们只是在第一层的默认红色多边形之上。使用第一层样式,第二层的标记会消失。

谢谢!

【问题讨论】:

    标签: google-maps-api-3 google-fusion-tables


    【解决方案1】:

    您只能在地图上设置一个 FusionTablesLayer 的样式。

    https://developers.google.com/maps/documentation/javascript/layers#fusion_table_styles

    样式只能应用于每个地图的单个 Fusion Tables 图层。您最多可以为该图层应用五种样式。

    【讨论】:

    • 您可以使用 FusionTables UI 来设置两个表格的样式(PolygonsMarkers)而不使用 javascript 样式(或仅将其用于其中一个表格)。
    • 我很乐意这样做。菜鸟问题,我如何让这两个融合风格的地图显示在同一张地图上?我所经历的只是显示默认样式,无论我如何在融合表中设置它们。谢谢。
    • 只需为每一层指定styleIdSee the docs了解详情。
    • 谢谢奥迪。您的建议让我找到了 Fusion Table Wizard,它可以满足我的所有需求,甚至更多!
    猜你喜欢
    • 1970-01-01
    • 2015-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-16
    • 2016-10-26
    • 1970-01-01
    相关资源
    最近更新 更多