简体   繁体   中英

Html with Google apps script.

I just start to play around with Google Html service, but I cant seem to get my project off the ground. I pieced together this code from the Google examples, but I cant get it to work. In a script document i have 2 files one is called Code.gs the other is Map.html. When I publish this script as a web App and then run it the page comes up black. I know that it is kinda working because if i insert a

Hello world

into the body, the web page shows Hello World. Bellow is the code for Code.gs and Map.html respectively

 function doGet() { return HtmlService.createHtmlOutputFromFile('Map'); } 

black

 <html> <head> <script type='text/javascript' src='https://www.google.com/jsapi'></script> <script type='text/javascript'> google.load('visualization', '1', {'packages': ['geochart']}); google.setOnLoadCallback(drawMarkersMap); function drawMarkersMap() { var data = google.visualization.arrayToDataTable([ ['City', 'Population', 'Area'], ['Rome', 2761477, 1285.31], ['Milan', 1324110, 181.76], ['Naples', 959574, 117.27], ['Turin', 907563, 130.17], ['Palermo', 655875, 158.9], ['Genoa', 607906, 243.60], ['Bologna', 380181, 140.7], ['Florence', 371282, 102.41], ['Fiumicino', 67370, 213.44], ['Anzio', 52192, 43.43], ['Ciampino', 38262, 11] ]); var options = { region: 'IT', displayMode: 'markers', colorAxis: {colors: ['green', 'blue']} }; var chart = new google.visualization.GeoChart(document.getElementById('chart_div')); chart.draw(data, options); }; </script> </head> <body> <div id="chart_div" style="width: 900px; height: 500px;"></div> </body> </html> 

This is because the library you using is not supported by caja. Caja is a engine that it will be used to check before it can be displayed to the user and currently, it support JQuery and JQuery UI, https://developers.google.com/apps-script/html_service#Caja . So if you wish to test you code, you might want to go http://caja.appspot.com/ and test it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM