如何添加一些仅加载 google maps api 的 javascript:
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
当我的应用程序在线时(navigator.onLine == true
)?
如何添加一些仅加载 google maps api 的 javascript:
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
当我的应用程序在线时(navigator.onLine == true
)?
使用动态脚本插入:
if(navigator.onLine) {
var script = document.createElement('script');
//You must use the callback parameter when loading the script asynchronously
script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&callback=initialize';
var scripts = document.getElementsByTagName('script');
scripts[0].parentNode.insertBefore(script, scripts[0]);
}
function initialize() {
//initialize map here
}