javascript - 谷歌表格与传单同步不起作用
问题描述
为了在传单地图中显示它们,我一直在使用我的 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 中复制而来的。问题在于某处的共享。有人可以建议该怎么做吗?
解决方案
它似乎与您在小提琴上的一个文件一起工作,当我粘贴您的一个谷歌表格链接时,点出现在波兰。
但他们在描述中有“未定义”。要解决此问题,您必须修改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>');
}
}
推荐阅读
- php - WooCommerce:删除存档上的添加到购物车按钮,但不在购物车中
- node.js - 试图提高 nodejs 的性能
- css - Bootstrap 4 复选框和下拉内联
- angular - 在 Angular 中,如何在上传前验证 zip 文件的密码
- php - 电子邮件 FILTER_VALIDATE_EMAIL 的验证不起作用,但我的错误不是 nbot 解决的功能不起作用
- javascript - 无法从 JSON 文件中提取数组字段。相反,我的代码返回“{}”
- javascript - 钩子 usKeyPress 和 useEventListener 之间的性能差异
- ios - 为什么 UIImagePickerController 中的图像尺寸大于原始尺寸?
- elf - 合并精灵部分
- html - CSS样条样条背景对象