Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 谷歌地图赢得';无法在Phonegap iOS应用程序中显示_Html_Ios_Google Maps Api 3_Cordova - Fatal编程技术网

Html 谷歌地图赢得';无法在Phonegap iOS应用程序中显示

Html 谷歌地图赢得';无法在Phonegap iOS应用程序中显示,html,ios,google-maps-api-3,cordova,Html,Ios,Google Maps Api 3,Cordova,我有一个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

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

$(文档).ready(函数(){
var initialLocation=new google.maps.LatLng(37.654,-77.980);
变量myOptions={
缩放:12,
中心:初始位置,
mapTypeId:google.maps.mapTypeId.ROADMAP
};
var map=new google.maps.map(document.getElementById(“map_canvas”),myOptions);
});

PhoneGap有一个用于外部URL/主机的白名单系统

从wiki:

此外,最新代码具有新的白名单功能。如果你是 引用外部主机时,必须在中添加主机 PhoneGap.plist在“ExternalHosts”键下。通配符可以。所以如果 您正在连接到“http://phonegap.com“,您必须添加 “phonegap.com”添加到列表中(或使用通配符“*.phonegap.com”,其中 也将匹配子域)

上面的代码段中有几个外部主机:

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

也许可以尝试在ExternalHosts中添加“*”,以确保这不是问题所在,然后在运行后添加更多特定的主机。

您必须将Google Maps希望加载的所有内容添加到ExternalHosts列表中。 我添加了以下内容,对我来说效果很好:

  • *.google.com
  • *.googleapis.com
  • *.gstatic.com

我对主机也有同样的问题,但您的“*.googleapis.com”解决方案起了作用。但是地图仍然没有出现,因为我没有API密钥,这解决了我的问题。希望它能帮助您,因为您的代码中没有API键。

API键在Google Maps Javascript API中不再需要。