您已在此页面上多次包含Google Maps API。这可能会导致意外的错误 [英] you have included the Google Maps API multiple times on this page. This may cause unexpected errors
问题描述
使用Google地图时出现两处错误:
- 警告:您已在此页面上多次包含Google Maps API。这可能会导致意想不到的错误。
- a为空(main.js)
不知道这两者之间是否有任何联系,但最终结果是我的页面无法加载地图。
这里是我的标签:
< script type =text / javascriptsrc =../ s / Jquery / jquery-1.6.1.min.js >< /脚本>
< script type =text / javascriptsrc =../ s / jquery.placeholder.min.js>< / script>
< script type =text / javascriptsrc =../ s / index.js>< / script>
< script type =text / javascriptsrc =../ s / Jquery / ui / jquery.ui.core.js>< / script>
< script type =text / javascriptsrc =../ s / Jquery / ui / jquery.ui.widget.js>< / script>
< script type =text / javascriptsrc =../ s / Jquery / ui / jquery.ui.position.js>< / script>
< script type =text / javascriptsrc =../ s / Jquery / ui / jquery.ui.autocomplete.js>< / script>
< script src =../ dd / markerclusterer_compiled.jstype =text / javascript>< / script>< script src =../ dd / dealers_js.jstype = text / javascript>< / script>< script type =text / javascriptsrc =http://maps.google.com/maps/api/js?sensor=false>< /脚本>
这里是我称之为谷歌地图的功能:
函数set_google_map(set_region)
{
var zoom;
var center;
switch(set_region){
caseusa:
zoom = 3;
center = new google.maps.LatLng(37.09,-95.71);
休息;
caseeurope:
zoom = 3;
center = new google.maps.LatLng(48.58,7.71);
休息;
caseeast:
zoom = 3;
center = new google.maps.LatLng(31,121);
休息;
默认值:
zoom = 1;
center = new google.maps.LatLng(35,5);
}
//创建地图
map = new google.maps.Map(document.getElementById('map'),options);
google.maps.event.addListener(map,'click',function(){
clean_icons();
if(infowindow)
infowindow.close();
});
map.setCenter(center);
map.setZoom(zoom);
// bounds = new google.maps.LatLngBounds();
}
以下是我的变数:
var UseridEncr;
var super_category =ATE;
var infowindow;
var map;
var bounds;
var image =../ dd / i / green.png;
var image_active =../ dd / i / red.png;
var mc;
var location_changed = true;
var current_region =usa;
var mcOptions = {gridSize:30,maxZoom:8};
var last_marker;
var last_marker_z;
var DealersData;
var markers = [];
var markers_selected = [];
claster_markers = [];
var current_view = 0;
myData = {};
var selected_items = [];
var total_selected = 0;
感谢您的及时答复。
解决方案我遇到了同样类型的问题。如果您的网页包含映射api 超过一次,则会发生这种情况。
我在我的情况中检查了
.js
也称为 maps api 的文件,因此请先检查您是否包含多次 maps api ,如果您,去掉那个。I get two error when using google map:
- Warning: you have included the Google Maps API multiple times on this page. This may cause unexpected errors.
- a is null (main.js)
i don't know if there is any connection between the two, but the final result is that my page cannot load the map.
here is my head tag:
<script type="text/javascript" src="../s/Jquery/jquery-1.6.1.min.js"></script> <script type="text/javascript" src="../s/jquery.placeholder.min.js"></script> <script type="text/javascript" src="../s/index.js"></script> <script type="text/javascript" src="../s/Jquery/ui/jquery.ui.core.js"></script> <script type="text/javascript" src="../s/Jquery/ui/jquery.ui.widget.js"></script> <script type="text/javascript" src="../s/Jquery/ui/jquery.ui.position.js"></script> <script type="text/javascript" src="../s/Jquery/ui/jquery.ui.autocomplete.js"></script> <script src="../dd/markerclusterer_compiled.js" type="text/javascript"></script><script src="../dd/dealers_js.js" type="text/javascript"></script><script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
here is the function which i call the google map:
function set_google_map(set_region) { var zoom; var center; switch (set_region) { case "usa": zoom = 3; center = new google.maps.LatLng(37.09, -95.71); break; case "europe": zoom = 3; center = new google.maps.LatLng(48.58, 7.71); break; case "east": zoom = 3; center = new google.maps.LatLng(31, 121); break; default: zoom = 1; center = new google.maps.LatLng(35, 5); } // Creating the map map = new google.maps.Map(document.getElementById('map'), options); google.maps.event.addListener(map, 'click', function(){ clean_icons(); if (infowindow) infowindow.close(); }); map.setCenter(center); map.setZoom(zoom); //bounds = new google.maps.LatLngBounds(); }
these are my variables:
var UseridEncr; var super_category="ATE"; var infowindow; var map; var bounds; var image="../dd/i/green.png"; var image_active="../dd/i/red.png"; var mc ; var location_changed=true; var current_region="usa"; var mcOptions = {gridSize:30, maxZoom: 8}; var last_marker; var last_marker_z; var DealersData ; var markers=[]; var markers_selected=[]; claster_markers=[]; var current_view=0; myData={}; var selected_items=[]; var total_selected=0;
thanks for your prompt answer.
解决方案I faced the same type of problem. This occurs if your web page including maps api more than one time.
I have checked in my case there was a
.js
file that was also calling maps api, so please first check if you are including maps api more than one time, if you are, remove the one.这篇关于您已在此页面上多次包含Google Maps API。这可能会导致意外的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!