将Fusion Table查询值加载到JS变量中? [英] Load Fusion Table query value into JS variable?

查看:61
本文介绍了将Fusion Table查询值加载到JS变量中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试在基本的默认Google Maps红色位置标记点上放置一个最终将成为动态大小的部分不透明填充圆.最初,表中的所有位置均已标记. 然后,此代码摘要可以很好地进行过滤,并且一次只能显示一个地名-在从填充表格的下拉列表中进行选择时.如果我插入静态地理坐标,则我的最后一部分代码将画一个圆. 但是一直在摸索,徒劳地搜索语法/方法,以将与Google Maps layer_0使用的查询响应参数相同的查询响应参数加载到我的变量circlePos中.我敢肯定,这也是我可以完成其他任务的一个关键障碍.举起手来,我的编程总体上是生锈的,但是我发现了稀缺的在线示例的学习路径,它们利用迅速变化的API版本...很尴尬.因此,任何帮助表示赞赏.

function changeMap_0() {
  var whereClause;
  var searchString = document.getElementById('search-string_0').value.replace(/'/g, "\\'");
  if (searchString != '--Select--') {
      whereClause = "'PlaceName' CONTAINS IGNORING CASE '" + searchString + "'";}
      layer_0.setOptions({
      query: {
      select: "col2",   //e.g. 54.742461,-1.884263 
      from: "1Fmd93Cnqv7rhJEFHIixl6wa1x-LuAH24z1AJKtw",
      where: whereClause }
  });
      var circlePos = //syntax to load value from the above query?
      new google.maps.Circle({ 
      center: new google.maps.LatLng(circlePos),          
      radius: 24000,
      map:map
 }); }

解决方案

FusionTablesLayer对象不会公开您需要的信息.您需要坐标地址编码列的地址.

您需要直接使用 GViz(示例) FusionTables API v1.0 来获取这些坐标.最简单的解决方案是将它们存储在表中.

上面的示例使用Google Maps API地理编码器对地址进行地理编码,结果可能与FusionTablesLayer上显示的位置不同.

包含示例的问题

I'm attempting to place, what will eventually be a dynamically sized, partial opacity filled circle over the basic default google maps red location marker dot. Initially all locations in the table are marked. This code abstract then works fine to filter, and only display one place name at a time - on selection from the table populated drop-down list. My last section of code will draw a circle, if I insert static geo co-ords. But been scratching my head and searching in vain over the syntax/method to load the same query response parameter that google maps layer_0 is using, into my variable circlePos. A key hurdle that'd let me get ahead with other tasks too I'm sure. Hands up, my programming is rusty in general, but I've found the learning path of scarce online examples, utilizing rapidly changing API versions... awkward. Hence any help appreciated.

function changeMap_0() {
  var whereClause;
  var searchString = document.getElementById('search-string_0').value.replace(/'/g, "\\'");
  if (searchString != '--Select--') {
      whereClause = "'PlaceName' CONTAINS IGNORING CASE '" + searchString + "'";}
      layer_0.setOptions({
      query: {
      select: "col2",   //e.g. 54.742461,-1.884263 
      from: "1Fmd93Cnqv7rhJEFHIixl6wa1x-LuAH24z1AJKtw",
      where: whereClause }
  });
      var circlePos = //syntax to load value from the above query?
      new google.maps.Circle({ 
      center: new google.maps.LatLng(circlePos),          
      radius: 24000,
      map:map
 }); }

解决方案

The FusionTablesLayer object does not expose the information you need. You need the coordinates of the geocoded address column.

You need to query the FusionTable directly using either GViz (example) or the FusionTables API v1.0 to get those coordinates. The simplest solution is to store them in your table.

The example above uses the Google Maps API geocoder to geocode the addresses, the results may differ from the position displayed on the FusionTablesLayer.

SO question containing the example

这篇关于将Fusion Table查询值加载到JS变量中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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