我有一个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
原文地址:https://www.jb51.cc/html/224228.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。