Uncaught ReferenceError: google is not defined(未捕获的 ReferenceError:未定义 google)
问题描述
我想使用地理定位和方向功能,但是有 google is not defined
错误.代码如下:
I want to use geolocation and direction function, but there is google is not defined
error. the code is as below:
function loadScript() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = "aHR0cHM6Ly9tYXBzLmdvb2dsZWFwaXMuY29tL21hcHMvYXBpL2pzP2tleT1teWtleSZhbXA7c2Vuc29yPXRydWU=" + "&callback=initialize";
document.body.appendChild(script);
}
好像loadScript不行!
It seems that the loadScript does not work!
var mapOptions = {
zoom : 13,
mapTypeId : google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
错误从这里跳出来.有谁知道如何弄清楚吗?我需要使用key来获取地理位置服务,所以我不能使用简单的
The error jumps out from here. Is anyone who know how to figure it out? I need to use key to get the geolocation service, so I cannot use simple
<script src="aHR0cHM6Ly9tYXBzLmdvb2dsZWFwaXMuY29tL21hcHMvYXBpL2pzP3NlbnNvcj10cnVl"></script>
推荐答案
如果你们在控制台中遇到错误,那么这里是我应用的简单解决方案.
If you people are getting Error in console then here is the simple solution that I applied.
包括给定顺序的脚本文件..
include the script files in given sequence..
<script type="text/javascript" src="aHR0cHM6Ly9tYXBzLmdvb2dsZWFwaXMuY29tL21hcHMvYXBpL2pzP3NlbnNvcj1mYWxzZQ=="></script>
<script type="text/javascript" src="anMvanF1ZXJ5LTEuOC4zLm1pbi5qcw=="></script>
您必须首先包含maps.googleapis.com/maps/api/js?sensor=false",然后使用 jquery 库并将其从两者下方删除(它会起作用.)我希望它一定会起作用.
You must first include 'maps.googleapis.com/maps/api/js?sensor=false' first then go for jquery library and remove it from below both (it will work.) I hope it will definitely work.
这篇关于未捕获的 ReferenceError:未定义 google的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:未捕获的 ReferenceError:未定义 google


- 失败的 Canvas 360 jquery 插件 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01