加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

html – Google地图不会显示在Phonegap iOS App中

发布时间:2020-12-14 19:33:28 所属栏目:资源 来源:网络整理
导读:我有一个PhoneGap iOS应用程序,并且这个 HTML将不会显示应用程序中的地图.我在Safari或FF中完美地看到了地图,但在应用程序中却没有.我该如何让这个工作? script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"/script scri
我有一个PhoneGap iOS应用程序,并且这个 HTML将不会显示应用程序中的地图.我在Safari或FF中完美地看到了地图,但在应用程序中却没有.我该如何让这个工作?
<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开始,以确保不是问题,然后添加更多的特定主机一旦它的工作.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读