2012-08-05 59 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