1

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

<!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 应用程序上使用 Google Maps 是否有不同/更好的方式,或者我需要在上面的代码中更改什么?谢谢。

4

2 回答 2

1

将您的脚本标签更改为:

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

我相信您使用的是 v2,如此处所述

于 2013-08-02T21:40:54.073 回答
1

在我的情况下,无法加载 google api,因为该应用程序没有访问互联网的权限。所以不要忘记在您的 AndroidManifest.xml 中为您的应用添加互联网访问权限

<uses-permission android:name="android.permission.INTERNET" />

对于其他功能(位置、相机等),请确保已为此应用和设备设置了相应的权限

于 2014-02-17T15:48:55.383 回答