我正在尝试在我们的网站上实现谷歌地图。
该网站基本上有一个页面,页面上的部分可以通过 jquery.load() 动态加载。
在这些部分之一中,另一个页面通过 jQuery.Load() 函数加载,该函数填充弹出窗口的内容(具有精美样式的 div)
现在,在 div 中,我正在使用 JqueryUI 选项卡控件,其中一个选项卡包含 google map 。
请查看我的代码:
<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?key=xxxxxxxxxx..&sensor=false&v=3&callback=initialize">
</script>
<script>
document.domain = '<?php echo $_SERVER["HTTP_HOST"]; ?>';
$(function() {
$("#tabs").tabs();
});
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644)
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
}
function loadScript() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'http://maps.googleapis.com/maps/api/js?key=..........&sensor=false&v=3&callback=initialize';
document.body.appendChild(script);
}
window.onload = loadScript;
</script>
map 加载成功,但出现以下错误: 1. 警告:您已在此页面多次包含 Google Maps API。这可能会导致意外错误。 2. 超出连接限制——这是不可能的
有什么帮助吗?
最佳答案
只需删除第一个脚本标签。 即
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/jskey=xxxxxxxxxx..&sensor=false&v=3&callback=initialize">
因为“loadScript()”已经加载谷歌地图API。
关于javascript - Google map V3 身份验证和重复问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20974848/