0

此问题的完整代码位于测试应用程序中

我正在尝试使用带有查询的谷歌融合表来显示数据库的子集。Project 类型 (handlePrjTypeKey) 的代码会产生预期的结果;但是,为 City 选择的代码没有(没有项目显示)。我花了相当多的时间试图找出原因并且不知所措。我已确认可以使用以下函数中使用的相同查询字符串手动查询 Google Fusion Tables 中的表并获得预期结果,但程序版本无法正常工作。

任何帮助或建议将不胜感激!

    function handlePrjTypeKey(queryString)
    {
    // Google Fusion PointFeat table
    var pntLayer = new google.maps.FusionTablesLayer({
          query: {
        select: 'ProjectType',
        from: pntCityTableId,
            where: queryString
      },
          map: GlobalMap
        });

    // Google Fusion LineFeat table
    var linLayer = new google.maps.FusionTablesLayer({
        query: {
        select: 'ProjectType',
        from: linCityTableId,
        where: queryString
        },
        styles: [{
            polylineOptions: {
            strokeColor: "#FF0000",
            strokeWeight: "2"
            }
        }],
          map: GlobalMap
        });

    // Google Fusion AreaFeat table
    var areaLayer = new google.maps.FusionTablesLayer({
        query: {
            select: 'ProjectType',
        from: areCityTableId,
            where: queryString
          },
          map: GlobalMap
        });
 }

function handleCityKey(queryString)
{
    // Google Fusion PointFeat table
    var pntLayer = new google.maps.FusionTablesLayer({
          query: {
        select: 'CityName',
        from: pntCityTableId,
            where: queryString
      },
          map: GlobalMap
        });

    // Google Fusion LineFeat table
    var linLayer = new google.maps.FusionTablesLayer({
        query: {
        select: 'CityName',
        from: linCityTableId,
        where: queryString
        },
        styles: [{
            polylineOptions: {
            strokeColor: "#FF0000",
            strokeWeight: "2"
            }
        }],
          map: GlobalMap
        });

    // Google Fusion AreaFeat table
    var areaLayer = new google.maps.FusionTablesLayer({
        query: {
            select: 'CityName',
        from: areCityTableId,
            where: queryString
          },
          map: GlobalMap
        });
}

表 ID 在 right.html 文件中定义,如图所示

  // To simplify my life I decided to just use a couple of global variables instead of passing parameters!
  // These three tables have the project geometry merged with the project data
  var pntTableId = '16uiLeoNQIIonp6JxsOpKDxzT1S391pP9BZ-RnVQ'; // The fusiontables table id, encrypted form, needed to access the project data
  var linTableId = '1EHx68dEBTB4-uCoW1KdjhV6n_40QYMNq3VcwGjI';
  var areTableId = '1mP2PIX-C3s9y3kqzicl0xrCzZyDNAs78tH04aYc';
  // These three tables have the project geometry merged with the project data and the cities impacted
  var pntCityTableId = '1LV4c5hf4TGei9O90jge3guhZJ5YDVVMjiOgqI0w'; // The fusiontables table id, encrypted form, needed to access the project data
  var linCityTableId = '1zq9xgR8mnebZGbpjWYU16PpdxzohKpxjLi9JtDk';
  var areCityTableId = '1xyOrrqbvVjQ30jEut0Fc68T4rv5prZ9cFXU4fQk';
  var datalink = null;
  var GlobalMap = null;
4

1 回答 1

1

查询无效。它返回错误:“无法解析查询”,加密 id 为 1mP2PIX-C3s9y3kqzicl0xrCzZyDNAs78tH04aYC 的表似乎不存在。

https://www.google.com/fusiontables/data?docid=1mP2PIX-C3s9y3kqzicl0xrCzZyDNAs78tH04aYc

QueryFusionTables 中的所有查询都返回错误,因为“datalink”变量为空(至少在市政/城市页面上)。

如果您不需要该功能,也许应该将其删除。您至少应该为其添加错误处理。

融合表层上没有显示数据的原因是 queryStiring "CityName = 'COCONUT+CREEK'" 不匹配任何行,CityName 列中的数据是 "COCONUT CREEK"。您需要将“+”翻译为“”(空格)(或将列中的空格更改为“+”)。

“选择”应该是几何列,来自文档

选择 | 字符串 | 一列,包含要在地图上显示的地理特征。有关有效列的信息,请参阅 Maps API 文档中的 Fusion Tables Setup。

改变:

var pntLayer = new google.maps.FusionTablesLayer({
      query: {
    select: 'CityName',
    from: pntCityTableId,
        where: queryString
  },
      map: GlobalMap
    });

至:

var pntLayer = new google.maps.FusionTablesLayer({
      query: {
    select: 'geometry',
    from: pntCityTableId,
        where: queryString
  },
      map: GlobalMap
    });
于 2013-07-11T16:33:59.760 回答