Google地图不会加载到我的PhoneGap Android应用程序中 [英] Google Maps Will Not Load In My PhoneGap Android App

查看:96
本文介绍了Google地图不会加载到我的PhoneGap Android应用程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用PhoneGap / Cordova时,是否可以使用Google Maps API V3进行移动应用程序开发?我的索引页面有一个指向地图页面的链接,其中包含以下内容:

Is it possible to use Google Maps API V3 for mobile app development when using PhoneGap/Cordova? My index page has a link to a map page that has the following in it:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
    <link rel="stylesheet" type="text/css" href="css/index.css" />
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"> 
    <title>Map Page</title>
</head>
<body>
    <div class="app">
        <div id="map-canvas"></div>
    </div>

    <script type="text/javascript" src="phonegap.js"></script>
    <script type="text/javascript" src="js/index.js"></script>
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/jquery.ui.map.full.min.js"></script>
    <script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
    <script type="text/javascript">
    app.initialize();
    </script>
    <script type="text/javascript">
    $('#map-canvas').gmap({'center': '57.7973333,12.0502107', 'zoom': 10, 'disableDefaultUI':false, 'callback': function() {}});
    </script>
</body>
</html>

我包含Google Maps jQuery插件和其他必要文件。当我在我的桌面浏览器中测试应用程序时,Ripple和(神秘地)在我的旧三星Galaxy S上的地图加载得很好。当我在Android模拟器或Galaxy S4上尝试它时,地图不会加载,我剩下一个空白页面。有没有不同的/更好的方式,我可以使用谷歌地图和Android应用程序,还是有我需要改变我的上述代码?感谢。

I'm including the Google Maps jQuery plugin and the other necessary files. When I test the app in my desktop browser, Ripple, and (mysteriously) on my old Samsung Galaxy S the map loads up just fine. When I try it in the Android emulator or on an Galaxy S4 the map does not load and I am left with an empty white page. Is there a different/better way I could be using Google Maps on and Android app or is there something I need to change in my above code? Thanks.

推荐答案

将您的脚本标记更改为:

Change your script tag to:

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false" />

我相信你使用的是v2,正如这里

I believe the one you are using is for v2 as stated here

这篇关于Google地图不会加载到我的PhoneGap Android应用程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆