Load Fusion Table query value into JS variable?

我怕爱的太早我们不能终老 提交于 2019-12-13 08:56:51

问题


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
 }); }

回答1:


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



来源:https://stackoverflow.com/questions/21222003/load-fusion-table-query-value-into-js-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!