我有一个 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/