html - Google map 不会显示在 Phonegap iOS 应用程序中

标签 html ios google-maps-api-3 cordova

我有一个 PhoneGap iOS 应用程序,并且这个 HTML 不会在应用程序中显示 map 。我在 Safari 或 FF 中完美地看到了 map ,但在应用程序中却看不到。我怎样才能让它发挥作用?

    <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/主机的白名单系统。

来自维基:

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).

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

  • maps.google.com
  • code.jquery.com

也许尝试将“*”添加到 ExternalHosts 以确保这不是问题所在,然后在它工作后添加更多特定主机。

关于html - Google map 不会显示在 Phonegap iOS 应用程序中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8146231/

相关文章:

javascript - IBM Worklight WL.JSONStore.QueryPart()。 json存储错误

html - 两个并排的文本 block ,如有必要,截断并在一个 block 中添加省略号

jquery - 提交表单而不重新加载页面

iphone - Facebook 演示应用程序无法在 iOS 上构建

ios - 以编程方式动态居中 2 行文本,每行长度大致相等

javascript - 如何获取 Google map 标记的 HTML?

html - 视差效果在浏览器中有效,但在移动设备中无效

javascript - geoXML3,如何加载文件夹中的所有KML文件?

javascript - CSV 字段导入格式问题

ios - 添加 SSL 证书会中断我与 iOS 应用程序的网络服务连接吗?