样式图标标记-融合表 [英] styling icons markers - fusion tables

查看:50
本文介绍了样式图标标记-融合表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是对像我这样的其他新手的帮助.

This is offered as assistance to other newbies like myself.

我花了很长时间努力弄清楚如何在我的融合表项目中为不同类别的标记分配不同的图标.我发现文档有限且令人困惑,并且我认为如果我感到困惑,那么其他人也可能会感到困惑.

I struggled quite a while to figure out how to assign different icons to different categories of markers in my fusion table project. I found the documentation limited and confusing, and I figure if I was confused then others probably are as well.

在其他人的帮助和大量测试的帮助下,我现在可以与您分享两种方法来实现这一目标.

With the help of others and lots of testing, I can now share with you two ways to accomplish this.

首先请注意,可从此处查看的一组数据中,可用于融合表的图标非常有限: http://www.google.com/fusiontables/DataSource?dsrcid=308519
放大漂浮在海洋上的图标,然后单击您想要了解其名称的图标.

First note, the icons available for fusions tables is very limited, from a single set that you can see here: http://www.google.com/fusiontables/DataSource?dsrcid=308519
Magnify the icons floating on the ocean and click on the ones you like to learn their names.

1.从融合表内部进行样式设置:
创建一个名称类似于样式"的列.确保将其TYPE设置为TEXT.
在该列中,添加要用于不同类别的图标的名称.
名称示例:星号,目标和"red_blank".
在地图视图中时,单击配置样式按钮.在点/标记图标"下,选择列".单击使用在列中指定的图标",然后从下拉列表中选择已设置的列名称,例如. 样式".
查看地图,您应该会看到显示的各种图标.

1. Styling from inside the fusion table:
Create a column with a name like "Styles". Be sure to set its TYPE as TEXT.
In the column, add the names of the icons you want to use for your different categories.
Examples of names: star, target and "red_blank".
When you are in map view, click on the CONFIGURE STYLES BUTTON. Under Points/Marker Icon, select Column. Click on "Use icon specified in a column", and from the dropdown, select the column name you have set eg. "Styles".
View the map and you should see your various icons displayed.

2.在您的javascript中进行样式设置:
在您的代码中添加一个样式部分.这是一个示例(在这种情况下,样式"类别用数字编码):

2. Styling in your javascript:
Add a styles section to your code. Here's an example (in this case the Styles categories were coded with numbers):

layer_2 = new google.maps.FusionTablesLayer({
  suppressInfoWindows:true,
  query: {
    select: 'Location',
    from: 'tableid' //add the id number of your table here, inside the quotes
  },

styles: [
  {where: "'style' = 14", markerOptions:{ iconName:"star"}}, // other landmarks
  {where: "'style' = 13", markerOptions:{ iconName:"wht_pushpin"}}, //businesses
  {where: "'style' = 11", markerOptions:{iconName:"red_blank"}}, //town houses
  {where: "'style' = 12", markerOptions:{ iconName:"orange_blank"}}, //country homes
  {where: "'style' = 15", markerOptions:{ iconName:"target"}},
  ]});

两种方法都有效.与这两者一起工作后,我现在认为我更喜欢在融合表中执行此操作,只是因为我发现可以保留JavaScript的越简单,对我来说越好.

Both approaches work great. Having worked with both I now think I prefer to do this inside the fusion table, just because I find the simpler I can keep the javascript, the better things work for me.

但是,通过JS控制它可以更轻松地动态更改图标,因为您只需要更改一行代码,而不用更改表中每一行的样式"列中的图标名称.

However, controlling it through the JS makes it easier to change icons on the fly, as you need only change one line of code, instead of changing the icon name in the Style column through every row of your table.

我希望这会有所帮助.
温迪

I hope this is helpful.
Wendy

推荐答案

还值得阅读这篇帮助文章,该文章描述了如何使用合并"功能快速创建将样式/图标分配给表中的行的列:

Also worth checking out this help article that describes how to use the Merge function to quickly create the column assigning styles / icons to rows in your table:

使用合并"按类别应用地图样式

这篇关于样式图标标记-融合表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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