Google地图不会显示在Phonegap iOS应用程式中 [英] Google Map won't show in Phonegap iOS App

查看:109
本文介绍了Google地图不会显示在Phonegap iOS应用程式中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PhoneGap iOS应用程式,并且这个HTML不会在应用程式中显示地图。我在Safari或FF完美地看到地图,但不是在应用程序。如何让这个工作?

I have an PhoneGap iOS app and have this HTML that won't show the map in the app. I see the map perfectly in Safari or FF but not in the app. How can I get this to work?

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

    <script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>  
    <script type="text/javascript">

        $(document).ready(function(){
                    var initialLocation = new google.maps.LatLng(37.654,-77.980);
                        var myOptions = {
                                        zoom: 12,
                                        center: initialLocation,
                                        mapTypeId: google.maps.MapTypeId.ROADMAP
                        };
                        var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
            });
</script>   
</head> 
<body>
<div data-role="content">   
    <!--images go here -->
    <div class="img_shadow" style="padding:4px;">
                    <div id="map_canvas" style="height:130px;"></div>
    </div>
</div>      
</div><!-- /page -->

</body>


推荐答案

PhoneGap有一个用于外部URL /主机的白名单系统。

PhoneGap has a whitelist system for external URLs/Hosts.

来自维基:


此外,最新的代码有新的白色列表功能。如果您是
引用外部主机,您将必须在
PhoneGap.plist在ExternalHosts键下添加主机。通配符确定。因此,如果
你正在连接到http://phonegap.com,你必须添加
phonegap.com到列表(或使用通配符* .phonegap.com
也会匹配子域)。

Also, the latest code has the new white-list feature. If you are referencing external hosts, you will have to add the host in PhoneGap.plist under the "ExternalHosts" key. Wildcards are ok. So if you are connecting to "http://phonegap.com", you have to add "phonegap.com" to the list (or use the wildcard "*.phonegap.com" which will match subdomains as well).

上面的代码段中有一些外部主机:

Your code snippet above has a few external hosts in it:


  • maps.google.com

  • code.jquery.com

也许尝试添加*到ExternalHosts开始,以确保这不是问题,然后添加更多的特定主机一旦工作。

Perhaps try adding "*" to ExternalHosts to start with to make sure that isn't the problem, then add more specific hosts once it's working.

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

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