[英]Google Maps Javascript API 204 errors
I'm using gmaps library in Laravel. 我在Laravel中使用gmaps库。 I've created an API key on google console and am passing my API key like this:
我已经在Google控制台上创建了一个API密钥,并且正在传递我的API密钥,如下所示:
<script type="text/javascript" src="http://maps.google.com/maps/api/js?key=API_KEY"></script>
(I know this isn't good practice, but for now I'm just testing it.) <script type="text/javascript" src="http://maps.google.com/maps/api/js?key=API_KEY"></script>
(我知道这不是一个好习惯,但是现在我正在测试。)
I am initializing the map using gmaps basic : 我正在使用gmaps basic初始化地图:
<html>
<div id='map'></div>
</html>
...
<script>
new GMaps({
div: '#map',
lat: -12.043333,
lng: -77.028333
});
</script>
Even though the map is loading, I keep getting these errors in the console: 即使地图正在加载,我仍会在控制台中遇到以下错误:
http://maps.googleapis.com/maps/gen_204?target=api&ev=api_viewport&cad=host:localhost%3A8000,v:25,r:1,mt:m,c:-12.043333%2C-77.028333,sp:0.01889x0.04892,size:1140x450,relsize:0.96,token:5qcrlsvho,src:apiv3,ts:9zqxca
http://maps.googleapis.com/maps/gen_204?target=api&ev=api_viewport&cad=host:localhost%3A8000,v:25,r:1,mt:m,c:34.149737%2C-118.135962,sp:0.01598x0.04892,size:1140x450,relsize:0.96,token:5qcrlsvho,src:apiv3,ts:9zqxmi
Can somebody explain to me what the errors are, or what causes them, or how I can fix them. 有人可以向我解释错误是什么,或者是什么原因导致的,或者我如何解决它们。
EDIT: 编辑:
I've noticed that as I zoom-in/zoom-out more errors occur. 我注意到在放大/缩小时会发生更多错误。
At the end of your body you need something like this: 在身体的末端,您需要这样的东西:
<script>
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -12.043333, lng: -77.028333},
zoom: 8
});
}
</script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?key=YOUR_KEY&callback=initMap"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.