2012-08-05 74 views
3

我想將我的Google Maps V3網絡應用轉換爲Google Apps腳本。如何將完整的Maps V3 API用於/加載到Google Apps腳本HTML文件(GAS Web App)?正常的標記方法似乎不起作用。使用Google Maps腳本中的完整Google Maps V3 API及其所有功能

我也試過Google Loader,但沒有成功。

即使URLFetch,但沒有運氣到目前爲止。

這是針對作爲Web應用程序發佈的「獨立腳本」。

回答

4

As of December 2014在Google Apps Script HtmlService中使用IFRAME sandbox mode可能會使用Google Maps JavaScript API v3。發佈下面的片段作爲一個Web應用程序,並生成在谷歌開發者控制檯允許*.googleusercontent.com/*作爲瀏覽器引用的公鑰:

function doGet() { 
    return HtmlService.createHtmlOutputFromFile('ui') 
        .setSandboxMode(HtmlService.SandboxMode.IFRAME); 
} 

- ui.html - (從Google Maps Dev. Docs

<!DOCTYPE html> 
<html> 
    <head> 
    <style type="text/css"> 
     html, body, #map-canvas { height: 100%; margin: 0; padding: 0;} 
    </style> 
    <script type="text/javascript" 
     src="https://maps.googleapis.com/maps/api/js?key=API_KEY"> 
    </script> 
    <script type="text/javascript"> 
     function initialize() { 
     var mapOptions = { 
      center: { lat: -34.397, lng: 150.644}, 
      zoom: 8 
     }; 
     var map = new google.maps.Map(document.getElementById('map-canvas'), 
      mapOptions); 
     } 
     google.maps.event.addDomListener(window, 'load', initialize); 
    </script> 
    </head> 
    <body> 
<div id="map-canvas"></div> 
    </body> 
</html> 
1

加載程序尚未在HtmlService中工作。

+0

這是不幸的,因爲Google Apps Script Web Apps似乎是我正在尋找的確切解決方案。關於何時可以從GAS訪問全功能Maps API的時間框架/計劃?有沒有解決方法? – user1541413 2012-08-06 14:43:31

+0

沒有解決方法。有時在不太遙遠的將來,但我不能承諾具體細節。 – 2012-08-06 18:55:02

+0

現在的未來比現在更接近嗎?即使使用本地沙箱,我也無法使這個或其他Google API起作用。 – Fred 2013-06-18 16:55:16