从Google电子表格获取GeoJSON

问题描述 投票:0回答:1

我希望可以选择从Google Spreadsheets保存geoJSON文件。

此问题已在这里提出:

https://gis.stackexchange.com/questions/140995/publishing-google-sheet-to-web-as-geojson-file

尽管插件在这里可用:

https://github.com/mapbox/geo-googledocs/

由于地理编码收到错误消息而无法使用:

https://github.com/mapbox/geo-googledocs/issues/42

UiApp已弃用。请改用HtmlService。

我很累赘将此插件提供的现有代码与为解决此问题而建议的代码结合在一起:

https://gist.github.com/hidrodixtion/c3a6b6ba7af624d1800625efb7a40fbd

 The code name is Geo.js as per the plugin provided above

我按如下所示将功能doGet放置在地址解析器上方:

// Global variables
 function doGet() {
  return HtmlService.createHtmlOutputFromFile('Index');
}

var ss = SpreadsheetApp.getActiveSpreadsheet(),
sheet = ss.getActiveSheet(),
activeRange = ss.getActiveRange(),
settings = {};

var geocoders = {
yahoo: {

...此处的另一部分代码:

https://raw.githubusercontent.com/mapbox/geo-googledocs/master/MapBox.js

不幸的是,它不起作用。

似乎我不知道该在哪里superseed the depreciated UiApp function with the HTML service。问题是,我不知道应该替换Geo插件中代码的哪一部分。这可能真的很有帮助,因为该插件也可以进行地理编码。enter image description here

我的另一部分组合如下:我更改了代码: //创建一个新的UI var app = UiApp.createApplication() .setTitle('导出GeoJSON') .setStyleAttribute('width','460') .setStyleAttribute('padding','20');

进入:

 var app = HtmlService.createHtmlOutput().setWidth(800).setHeight(600);
.setTitle('Export GeoJSON') //line 105
.setStyleAttribute('width', '460')
.setStyleAttribute('padding', '20');

但是现在保存后,我得到了:语法错误。 (第105行,文件“ Geo”)

我从这里获取了此代码:

https://gist.github.com/hidrodixtion/c3a6b6ba7af624d1800625efb7a40fbd第141行

有人知道如何解决此问题吗?

javascript google-sheets geojson
1个回答
0
投票

点击链接可找到适合您任务的完整解决方案:https://gsuite.google.com/marketplace/app/maps_for_sheets/268502135031https://apps.myrout.es/mfs您可以使用公式= gsGetPlaceDetailsJSON()此功能需要附加设置中的Google API密钥。

© www.soinside.com 2019 - 2024. All rights reserved.