[英]Mapbox data with google sheets
我正在努力開發一個眾包網站,該網站從Google表單獲取信息並在地圖上顯示此信息。 我正在使用mapbox,正在尋找一種方法來獲取Google電子表格中的數據點(含經緯度信息)以自動顯示在地圖上。 任何提示將不勝感激,謝謝!
我正在做一個類似的項目。
我“發布”了我的Google電子表格:“ file > Publish To Web
。 您應該會看到一個包含工作表URL的彈出窗口:
https://docs.google.com/spreadsheets/d/[your ID here]/pubhtml
獲得ID
,就可以在您的網站上使用它:
// ID of the Google Spreadsheet
var spreadsheetID = 'fakeExample';
// Make sure it is public or set to `Anyone with link can view`
var url = "https://spreadsheets.google.com/feeds/list/" + spreadsheetID + "/od6/public/values?alt=json";
$.getJSON(url, function(data) {
var entry = data.feed.entry;
$(entry).each(function(){
//do stuff with each entry in your spreadsheet
// for example, build a GeoJSON object with your lat/lons or add an individual marker
// ex: add the 'country' column to the `results` box
$('.results').prepend('<h2>'+this.gsx$country.$t+'</h2>);
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.