我有特殊的情况,可以真正使用一些帮助。我有一个html构建器,每次刷新该网站时,都会添加其他脚本标记。这是一个严重的问题,因为我使用的是Google Maps API,并且每次刷新页面时都会添加以下脚本标记:
< script src =maps.gstatic/intl/en_us/mapfiles/api-3/9/19/main.jstype =text / javascript>< / script>不幸的是,这是我能够为这个项目开发页面的唯一方法。 (你可以想象我的沮丧>。)
基本上,如果这个脚本标记在html文档中存在多次,它会产生一个错误 Uncaught TypeError:Object#< Object>没有方法加载,这会阻止Google Maps API呈现我的地图。 我的问题:有什么方法可以阻止Google API动态添加此脚本标记,或者在文档有机会加载它之前将其删除,或让文档完全忽略它?任何帮助都可以帮助我在今天早些时候睡一觉。)
解决方案您不应该使用include。使用记录的包含:
< script type =text / javascript src =maps.googleapis/maps/api/js?key=YOUR_API_KEY& ;传感器= SET_TO_TRUE_OR_FALSE> < / script>如果密钥是API控制台密钥并且不是必需的,并且传感器是否使用位置传感器或不是。
I have a special situation and could really use some help. I have an html builder and every time I refresh the site it adds additional script tags. This is a serious issue because I am using Google Maps API and it keeps adding the following script tag each time I refresh the page:
<script src="maps.gstatic/intl/en_us/mapfiles/api-3/9/19/main.js" type="text/javascript"></script>Unfortunately this is the only way I will be able to develop pages for this project. (You can imagine my frustration >.<).
Basically, if this script tag exists more than one time on the html document it raises an error Uncaught TypeError: Object #<Object> has no method 'Load' that prevents the Google Maps API from rendering my maps.
My question:
Is there any way I can prevent Google's API from dynamically adding this script tag, or remove it before the document has the opportunity to load it, or have the document completely ignore it? Any assistance will help me get to sleep a little earlier this morning :)
解决方案You should not be using that include. Use the documented include:
<script type="text/javascript" src="maps.googleapis/maps/api/js?key=YOUR_API_KEY&sensor=SET_TO_TRUE_OR_FALSE"> </script>Where the key is an API console key and is not required and the sensor is whether you are using a position sensor or not.
更多推荐
Google地图加载两次
发布评论