简体   繁体   English

带侧边栏的Fusion Tables和地图:从非洲地图示例中的数字ID到加密ID

[英]Fusion Tables & Map w/sidebar: From numeric to encrypted IDs in Africa map sample

Thanks to all for helping me learn so far! 谢谢大家到目前为止所提供的帮助!

I've had to change my previous map based on client feedback, and I'm now attempting to recreate the following API v3 Example: Fusion Tables Layer example from @geocodezip: 我不得不根据客户的反馈来更改以前的地图,现在尝试重新创建以下API v3示例: @geocodezip中的Fusion Tables Layer示例:

http://www.geocodezip.com/v3_FusionTables_AfricaMap_kml_sidebar.html http://www.geocodezip.com/v3_FusionTables_AfricaMap_kml_sidebar.html

I've carefully copied and pasted and changed the original code into my page, but I'm running into problems where: 我已经仔细地复制和粘贴并将原始代码更改为我的页面,但是遇到以下问题:

a.) The infoWindows are not being suppressed, and new ones are not created; a。)infoWindows没有被取消,也没有创建新的窗口;

b.) Clicking items in the sidebar has no effect on the map. b。)单击侧边栏中的项目对地图没有影响。

My guess is that it has something to do with the new query syntax and encrypted IDs, whereas the sample code (the Africa map) is based on numeric IDs. 我的猜测是,它与新的查询语法和加密的ID有关,而示例代码(非洲地图)是基于数字ID的。 I think I've flubbed it up. 我想我已经很烦了。

My question is: How can I change/update my code to make my map function like the Africa map example? 我的问题是:如何更改/更新代码以使地图功能像非洲地图示例一样? Thank you! 谢谢!

My map: http://hepac.ca/map/ 我的地图: http : //hepac.ca/map/

My Fusion Table: https://www.google.com/fusiontables/data?docid=1DxjRqzjtC7-Oryt8N9ZaJ0n1IXRllDjodnbEJYo 我的Fusion Table: https //www.google.com/fusiontables/data?docid = 1DxjRqzjtC7-Oryt8N9ZaJ0n1IXRllDjodnbEJYo

What I think is the relevant code: 我认为是相关的代码:

function createSidebar() {
  // https://www.google.com/fusiontables/api/query?sql=SELECT%20ROWID,%20%2A%20FROM%20564705

  //set the query using the parameter
  var queryText = encodeURIComponent("http://www.google.com/fusiontables/gvizdata?tq=SELECT * FROM 1DxjRqzjtC7-Oryt8N9ZaJ0n1IXRllDjodnbEJYo");
  var query = new google.visualization.Query(queryText);
  var queryText = encodeURIComponent("SELECT 'Description', 'Network', 'Contact', 'Email', 'Latitude', 'Longitude' FROM 1DxjRqzjtC7-Oryt8N9ZaJ0n1IXRllDjodnbEJYo");
  var query = new google.visualization.Query('http://www.google.com/fusiontables/gvizdata?tq='  + queryText);


  //set the callback function
  query.send(getData);

}

And: 和:

layer = new google.maps.FusionTablesLayer({
      query: {
        select: "col2",
        from: "1DxjRqzjtC7-Oryt8N9ZaJ0n1IXRllDjodnbEJYo",
        where: ""
      },
      suppressInfoWindows: true
    });  

  layer.setMap(map);

The infoWindows are being suppressed. infoWindows被禁止。 There is a 'click' listener in your code that causes them to be displayed: 您的代码中有一个“单击”侦听器,使它们显示出来:

  google.maps.event.addListener(layer, "click", function(event) {
    infoWindow.close();
    infoWindow.setContent(event.infoWindowHtml);
    infoWindow.setPosition(event.latLng);
    infoWindow.open(map);
  });

My Javascript errors seemed to be related to the number of columns I was calling from the Fusion Table. 我的Javascript错误似乎与我从Fusion Table调用的列数有关。 Made these fixes and it works OK: 进行了这些修复,可以正常工作:

var queryText = encodeURIComponent("SELECT 'Description', 'Network', 'Contact', 'Website', 'Email', 'Latitude', 'Longitude' FROM 1DxjRqzjtC7-Oryt8N9ZaJ0n1IXRllDjodnbEJYo");

and, later: 然后:

function myFTclick(row) {
   var Description = FTresponse.getDataTable().getValue(row,0);
   var Network = FTresponse.getDataTable().getValue(row,1);
   var Contact = FTresponse.getDataTable().getValue(row,3);
   var Email = FTresponse.getDataTable().getValue(row,4);
   var lat =  FTresponse.getDataTable().getValue(row,5);
   var lng =  FTresponse.getDataTable().getValue(row,6);
   var position = new google.maps.LatLng(lat, lng);

I was able to get it running by playing with the column values -- eg, .getValue(row, x) -- though I don't know how to find the correct numerical value for "x." 我可以通过处理列值(例如.getValue(row,x))来使其运行,尽管我不知道如何为“ x”找到正确的数值。 I did it by trial and error. 我通过反复试验做到了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM