Android:Google map 不适用于 Phonegap

标签 android google-maps cordova google-maps-api-3

我正在尝试让 Android 的 Google-Map.api 与 Phonegap 一起使用。但我无法找出问题所在。到目前为止我已经尝试了一切。请检查我的代码。我没有收到任何错误,并且我还包含了 jQueryMobile。对于困惑的代码表示歉意。

索引.html: -包括所有种类的东西-

Google.html:

   <body>
<div data-role="page" id="foo" data-theme="c">
    <div data-role="content">
        <div id="map_canvas"></div>
    </div>
</div>
<script type="text/javascript" src="googlemap.js"></script>
<script type="text/javascript">
    function onDeviceReady() {
        var map = new GoogleMap();
        map.initialize();
    }
</script>

googlemap.js 与本教程中看到的相同: christianengvall.se

对 Google.html 的 anchor 超文本引用包含 ref="external"属性。不知道重要不重要。

我还在 res/xml/cordova.xml 中添加了白名单(最新的 2 版?)

我的 list 文件拥有 android 可能拥有的所有权限。 (暂时)

当我在真实设备(三星 Galaxy S3)上运行/调试此页面时,出现白屏。

一个可能的问题可能是 Google.html 的数据角色属性。也许有类似 data-role="mapload"的东西。

如果您需要更多信息,请询问我。

//编辑

还是不行。我找到了另一个解决方案,尽管这是一个大困惑。如果有人能够上传好的代码,请上传

最佳答案

您的代码应该没问题也就是说,如果您的 CSS 正确,请禁用脚本,然后添加到 CSS 文件中:

#map_canvas {background: red;}

看到红色框了吗?如果没有,则给它一个高度,如果您不使用页脚,那么在 jquerymobile 中 height: 100% 是一个很好的高度,因为它在内容上方流动(标题也可以)。如果您确实使用页脚并想要 100% 高度,请使用 $("#map_content").css("height", ($("*[data-rel=content]").height()- $("*[data-rel=footer]").height())+"px");

其他一些提示:

如果您遇到问题,请尝试 adb logcat(如果您不喜欢终端,Eclipse 中有一个窗口),它可以给您一些指示。

据我所知,属性 rel=external 是无关紧要的。

我使用的白名单是:

<access origin="http://127.0.0.1*"/> <!-- allow local pages -->

<access origin="http://google.com" subdomains="true"/>
<access origin="http://gstatic.com" subdomains="true"/>
<access origin="https://google.com" subdomains="true"/>
<access origin="https://gstatic.com" subdomains="true"/>

关于Android:Google map 不适用于 Phonegap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12688083/

相关文章:

android - 从右侧使用 SlidingPaneLayout?

java - 错误找不到符号变量UTF_8 android studio

google-maps - 移动Safari崩溃(内存不足)

android - 在 ionic 中,将什么添加到位于 config.xml 文件中的描述和自动标记中。他们有什么用?

android - 如何在 flutter 中为 facebook 生成 key 哈希

android - 由于窗口没有焦点而丢弃事件

android - Webview 仅在第一次加载

java - 谷歌地图AndroidRuntime致命异常: main

css - 如何在动态加载的 html 内容上应用 css (jquery mobile+backbone+phonegap)

javascript - Cordova 无法加载 platformapi