具有两个Fusion Table图层的Google地图不显示第二层 [英] Google map with two Fusion Table layers does not display second layer

查看:69
本文介绍了具有两个Fusion Table图层的Google地图不显示第二层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张显示两个融合表图层的地图.在Google地图中创建图层时,我都使用styleId属性设置了样式,以采用Fusion Table UI中定义的样式,而不是使用styles属性.在地图文档中,它提到最多可以融合5个表格图层,其中之一被设置样式.

I have a map that is displaying two fusion table layers. I have styled them both using the styleId attribute to take the styles defined in the Fusion Table UI instead of using the styles attribute when creating the layer in Google maps. From the maps docs, it mentions that you can have up to 5 fusion table layers, with one of them being styled.

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

Styles can only be applied to a single Fusion Tables layer per map. You may apply up to five styles to that layer.

我还不是100%清楚的是,这是否仅适用于内联样式,例如:

What I'm not 100% clear on is if this applies to inline styles only, e.g.:

layer1 = new google.maps.FusionTablesLayer({
  query: {
    from: table1Id
  }, 
  styles: [
    {markerOptions: {iconName: 'red_blank'}, where: 'age > 50'},
    {markerOptions: {iconName: 'grn_blank'}, where: 'age <= 50'}
  ]
});

layer2 = new google.maps.FusionTablesLayer({
  query: {
    from: table2Id
  },
  styles: [  // This won't work because you can only style one table inline
    {markerOptions: {iconName: 'red_blank'}, where: 'age > 50'},
    {markerOptions: {iconName: 'grn_blank'}, where: 'age <= 50'}
  ]
});

或是否也适用于融合表用户界面中定义的样式:

or if it also applies to styles defined in the fusion table UI:

layer1 = new google.maps.FusionTablesLayer({
  query: {
    from: table1Id
  }, 
  options: {
    styleId: 2,   // Obtained from the fusion table UI
    templateId: 1 // Obtained from the fusion table UI
  }
})

layer2 = new google.maps.FusionTablesLayer({
  query: {
    from: table2Id
  }, 
  options: {
    styleId: 2,   // Obtained from the fusion table UI
    templateId: 1 // Obtained from the fusion table UI
  }
})

根据我对文档的阅读,看来这只是多层中不允许的第一种类型.

From my reading of the docs, it would seem that it's only the first type that is not allowed on multiple layers.

在Google Maps文档中实际上没有提到样式表的styleId方法,但这是当您发布"地图时在Fusion Tables中生成的嵌入代码的样子,并且实际上适用于个人层.

The styleId way of styling a table is actually not mentioned in the Google Maps docs, but this is the way the embed code generated in Fusion Tables when you "Publish" a map looks like, and it actually works for individual layers.

如果同时启用两个图层(layer1.setMap(map)),则仅显示其中一个图层.如果我禁用了一层,则另一层会正确显示.

If I enable both layers (layer1.setMap(map)), only one of the layers gets displayed. If I disable a layer, the other one appears correctly.

任何帮助将不胜感激.

推荐答案

它可以与混合内联样式和styleId一起使用.

It works with mixing inline-styles and styleId.

具有5层,4层使用styleId和1层使用5种内联样式的演示,如您所见,结果与预期的9种不同样式的标记有关:

Demo with 5 layers, 4 layers use styleId and 1 layer uses 5 inline-styles , as you see the result is as expected 9 different styled markers: http://jsfiddle.net/doktormolle/Zk2CE/

尝试的问题:您总是在query中使用相同的where子句(当前没有where子句,将选择所有行).

The problem with your attempt: you are always using the same where-clause in the query(currently there is no where-clause, all rows will be selected).

当您以样式定义where子句时,这会将样式应用于所选项目,所有其他项目(不会与style中的任何where子句匹配的项目)默认样式将被应用(例如标记的红点)

When you define a where-clause in a style this will apply the style to the selected items, to all other items(that will not be matched by any where-clause in a style) the default-style will be applied(e.g. a red dot for a marker)

结果:当query选择超过1层的特定行(项目)时,只能将1 style/styleId应用于这些项目(通常是最后一层设置的样式)已添加到地图中).

The result: when specific rows(items) will be selected by the query of more than 1 layer, only 1 style/styleId may be applied to these items(usually the style set with the last layer that has been added to the map).

这篇关于具有两个Fusion Table图层的Google地图不显示第二层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆