外部脚本build.phonegap 3.1.0

时间:2013-11-28 11:29:48

标签: google-maps cordova

我无法通过Android build.phonegap应用加载外部脚本(具体是谷歌地图)。我已经有好几天这个问题,并尝试了很多可能的解决方案。

我构建了一个非常简单的单页应用,可以调用并显示谷歌地图。 我在浏览器中运行它,一切都很好。 在我通过build.Phonegap运行应用程序后,它无法在设备中加载外部谷歌地图(google nexus)。

任何帮助都会很棒!

这是我的index.html

<!DOCTYPE html>
<html>
    <head>
        <title>Simple Map</title>
        <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
        <meta charset="utf-8">
        <style>
            html, body, #map-canvas {
                height: 100%;
                margin: 0px;
                padding: 0px
            }
        </style>
        <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
        <script>
            var map;
            function initialize() {
                var mapOptions = {
                zoom: 8,
                center: new google.maps.LatLng(-34.397, 150.644)
            };
            map = new google.maps.Map(document.getElementById('map-canvas'),
            mapOptions);
            }

            google.maps.event.addDomListener(window, 'load', initialize);
        </script>
        <script src="phonegap"></script>
    </head>
    <body>
        <div id="map-canvas"></div>
    </body>
</html>

和我的config.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns = "http://www.w3.org/ns/widgets"
    xmlns:gap = "http://phonegap.com/ns/1.0"
    id        = "org.fifedirect.mapapp"
    versionCode="1"
    version   = "1.0.0">
    <name> My Map APP</name>
    <description>
        Test to check if maps are working       
    </description>
    <author href="" email="steven.gardner-crm@fife.gov.uk">
        Steven Gardner
    </author>
    <preference name="phonegap-version" value="3.1.0" />
    <preference name="orientation" value="portrait" />
    <preference name="target-device" value="universal" />
    <preference name="fullscreen" value="false" />
    <preference name="webviewbounce" value="true" />
    <preference name="prerendered-icon" value="true" />
    <preference name="stay-in-webview" value="true" />
    <preference name="ios-statusbarstyle" value="default" />
    <preference name="detect-data-types" value="true" />
    <preference name="exit-on-suspend" value="false" />
    <preference name="show-splash-screen-spinner" value="true" />
    <preference name="auto-hide-splash-screen" value="true" />
    <preference name="disable-cursor" value="false" />
    <preference name="android-minSdkVersion" value="7" />
    <preference name="android-installLocation" value="internalOnly" />
    <preference name="splash-screen-duration" value="5000" />
    <preference name="load-url-timeout" value="20000" />
    <gap:platform name="android" />
    <access origin="*" subdomains="true"  />
</widget>

1 个答案:

答案 0 :(得分:0)

这看起来不正确:

<script src="phonegap"></script>

您是否尝试将其安装到4.4仿真器并使用Chrome DevTools通过'chrome:// inspect'进行调试?

信息:https://developers.google.com/chrome-developer-tools/docs/remote-debugging#debugging-webviews