如何使用来自两个 Google Fusion 表的数据?

How to use data from two Google Fusion tables?

我正在尝试在美国和加拿大创建 "service areas" 的 google 地图,偶然发现了这种融合 table 层的东西并认为它会很好,但我我有问题。

  1. 我无法创建融合 table 并在不支付 google 的情况下实现 public,没办法,我将使用现有的 public tables.

  2. 我需要将样式应用于融合 table 层,但我正在加载 2 个融合 tables(层)并且 API 只允许样式要添加到一层。

这是我的代码:

  <script>
    function initMap() {
      // Styles a map in night mode.
      var map = new google.maps.Map(document.getElementById('map'), {
        center: {lat: 40.237395466608156, lng: -93.68512878417971},
        zoom: 3.9,
        styles: []

      });

      var usa_geometry = new google.maps.FusionTablesLayer({
        query: {
          select: 'geometry',
          from: '1ZZ8j0NDbs2dilcQWjLh9xI7qIJso6DgYAoGTbA',
          where: "STATE IN ('North Dakota', 'Minnesota', 'Wisconsin', 'Ohio', 'Indiana', 'Iowa', 'Illinois', 'Kentucky', 'Missouri', 'Tennessee', 'Arkansas', 'Florida', 'Alabama', 'Mississippi', 'Louisiana', 'Texas', 'Oklahoma', 'Kansas', 'Nebraska', 'South Dakota')",
        },
        styles: [
          { 
            polygonOptions: {
            fillColor: "#006db7",
            strokeColor: "#006db7",
            fillOpacity: ".5",
          },
        }],

        map: map,
        suppressInfoWindows: true
      });

      var canada_geometry = new google.maps.FusionTablesLayer({
        query: {
          select: 'geometry',
          from: '1auwG6s4axorHR-QAX3UDXL544pSEXlbxmyu6xvJC',
          where: "Place IN ('Quebec', 'Ontario', 'Manitoba')",

        },
        styles: [
          { 
            polygonOptions: {
            fillColor: "#006db7",
            strokeColor: "#006db7",
            fillOpacity: ".5",
          },
        }],

        map: map,
        suppressInfoWindows: true
      });

    };

  </script>

所以:

  1. 有没有办法在本地使用融合table多边形数据?即导出 CSV 文件并加载它?

  2. 有没有办法在一个地图图层中从(加入)2 个融合 tables 加载数据?

  3. 还有其他我忽略的选项吗?

Is there a way to use the fusion table polygon data locally? i.e. export the CSV and load that?

是的,一个Fusion Table can be downloaded as KML, which you can use third-party apps/libraries such as toGeoJson to load in the app as GeoJSON

Is there a way to load data from (join) 2 fusion tables in one map layer?

您必须 merge the tables through the Fusion Tables UI 进入一个 Fusion Table 并加载该层。

is there another option I am overlooking?

是的,因为您消息的第一部分不正确:"I cannot create a fusion table & make it public without paying google...."

您可以创建 Public or Unlisted 融合 Table,而无需支付 Google。

此外,当转到 created Fusion Table in the UI,选择 Tools->Publish 并选择 "Get HTML and JavaScript" 时,您会看到以下未记录的选项“optionsFusionTablesLayer:

layer = new google.maps.FusionTablesLayer({
  map: map,
  heatmap: { enabled: false },
  query: {
    select: "col12",
    from: "1ClpNLfPQnhEex1KvGg5FrHPgzXgSu1ZvFEL9a2l1",
    where: ""
  },
  options: {
    styleId: 2,
    templateId: 2
  }
});

您可以使用 options 覆盖 Javascript API 应用的默认样式,并使用您在 Fusion Tables [=49] 中定义的样式=].

这里是 simple sample JSBin 显示 Javascript 中为 usa_geometry 定义的 Fusion Table 样式,而 Fusion Table 中定义的 Fusion Tables UI 对于 canada_geometry: