简体   繁体   中英

Google apps script html service and loading the Google maps javascript api V3

This javascript code on the page won't show the map. any suggestions? Is it the Caja sanitizer thats blocking the execution? Thankx! Cor

    <!DOCTYPE html>
    \\To load the APIs. I have found this code on https://developers.google.com/loader/;
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
   \\next load then specific API module with parameters and Callback
    function loadMaps(){
        google.load("maps", "3",{"callback" : mapsLoaded()}, sensor=false, key="AIzaSyBfB1qRhJJiHGFUNtI87yfTrVLx-C8YYp4");
      }
    </script>
    <script type="text/javascript"> 
      var geocoder;
      var map;
      function mapsLoaded() {
    //this is how far the code is executed;
        alert("br");
        var latlng = new google.maps.LatLng(52.2989, 4.9219);
    //this alert does not show up;
        alert(latlng);
        var mapOptions = {
          zoom: 8,
          center: latlng,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        }
            map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
      }

    </script> 

    <body onload="loadMaps()">
      <div id="map_canvas" style="width: 100%; height: 200px;"></div>
    </body> 
    </html>

No Google APIs are supported by HtmlService/Caja yet. We are working hard on making that pass sanitization.

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