首页 > 解决方案 > 谷歌表格与传单同步不起作用

问题描述

为了在传单地图中显示它们,我一直在使用我的 GoogleSheets 文件。

我发现了相当多的建议如何做到这一点:

https://rdrn.me/leaflet-maps-google-sheets/ - 这个是主要的

如何使用 tabletop.js 将标记添加到传单地图?- 这是使用Fiddle的示例之一。与此处相同: 使用 tabletop.js 的传单地图中的标记为什么它不起作用? https://jsfiddle.net/a21yb4uq/

所有这些看起来都很简单,但是一旦我粘贴了我自己的链接,地图上就没有任何内容。

我也尝试使用File -> Publish to the web选项以及Share - share to the web

没有改变。

这些示例中获取的链接如下所示:

         function init() {
       Tabletop.init({
        key: 'https://docs.google.com/spreadsheets/d/1pQOKxyrqjyzI0gGOwkXTaHCoBjg-voJ_Xh7AUbU2Z5o/edit?usp=sharing',
       callback: addPoints,
       simpleSheet: true
      })
    }
     init()

和第二

   function init() {
    Tabletop.init({
     key: 'https://docs.google.com/spreadsheets/d/1BTlWo-T636OCGK-tRMHRP55MQ24OwQ-ZF9yOszyppxk/edit?usp=sharing',
     callback: addPoints,
      simpleSheet: true
     })
   }
   init()

所以在他们两个中,链接都结束了=sharing,这意味着数据只共享到了网络上

我的链接如下所示:

   https://docs.google.com/spreadsheets/d/1pQOKxyrqjyzI0gGOwkXTaHCoBjg-voJ_Xh7AUbU2Z5o/edit?usp=sharing


   https://docs.google.com/spreadsheets/d/1yH4TpDwIJB7v2nZqS7WHl_E11_-Gcdo4fwzckXGpuDY/edit?usp=sharing

我的列/数据没有问题,因为其中一个示例是从 JsFiddle 中复制而来的。问题在于某处的共享。有人可以建议该怎么做吗?

标签: javascriptgoogle-sheetsleaflet

解决方案


似乎与您在小提琴上的一个文件一起工作,当我粘贴您的一个谷歌表格链接时,点出现在波兰。

但他们在描述中有“未定义”。要解决此问题,您必须修改addPoints


function addPoints(data, tabletop) {
  for (var row in data) {
    var marker = L.marker([
      data[row].Latitude,
      data[row].Longitude
    ]).addTo(map);
    marker.bindPopup('<strong>' + 
      data[row].Miasto +  // <- or anything you want
      '</strong>');
  }
}

推荐阅读