[英]Google Apis Map on my cordova jquery app doesn't work
I'm using cordova with jquery mobile. 我正在将Cordova与jquery mobile一起使用。 When I try to insert Maps of google Maps Apis, the maps doesn't appear.
当我尝试插入Google Maps Apis地图时,这些地图没有出现。 I have not understood the problem yet.
我还不了解问题。 My code(api key removed):
我的代码(删除了API密钥):
<div id="mappagps">Cavolo</div>
<script>
var map;
function initMap() {
map = new google.maps.Map(document.getElementById("mappagps"), {
center: {lat: -34.397, lng: 150.644},
zoom: 8
});
}
</script>
<script src="js/my_geoloc.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key= *your_api_key* "></script>
And in the last raw of index.html I put: initMap() 在index.html的最后一个原始文件中:initMap()
You have forgotten to set the callback for the google map script to call when he's finished: add &callback=initMap
at the end of your google map script. 您已经忘记为Google地图脚本设置回调以在他结束时调用:在Google地图脚本的末尾添加
&callback=initMap
。 (and also forgotten to give your div dimensions as said in Hasta Tamang's comment) (也忘了像Hasta Tamang的评论中所述给您的div尺寸)
<div id="mappagps" style="width: 100px; height: 100px">Cavolo</div> <script> var map; function initMap() { map = new google.maps.Map(document.getElementById("mappagps"), { center: {lat: -34.397, lng: 150.644}, zoom: 8 }); } </script> <!-- commented because we don't have this file: <script src="js/my_geoloc.js"></script>--> <script src="https://maps.googleapis.com/maps/api/js?key= *your_api_key *&callback=initMap"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.