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

前端之家收集整理的这篇文章主要介绍了html – Google地图不会显示在Phonegap iOS App中前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个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开始,以确保不是问题,然后添加更多的特定主机一旦它的工作.

原文链接:https://www.f2er.com/html/224228.html

猜你在找的HTML相关文章