[英]Cordova & jquery mobile google maps is not loading
I have an application where I use the google maps api, first it was working perfectly now the map is not loaded as it should. 我有一个使用google maps api的应用程序,首先它运行良好,现在未按需加载地图。 I tried to implement this: LINK
我尝试实现此: LINK
But when I change something and build it to my phone it suddenly shows only a gray area. 但是,当我更改某些内容并将其构建到手机中时,它突然仅显示灰色区域。
Here is my code how it worked first: 这是我的代码首先如何工作的:
<div data-role="page" id="map">
<div data-role="header">
<a href="#dashboard" class="ui-btn ui-icon-carat-l ui-btn-icon-notext ui-alt-icon ui-corner-all ui-btn-left" data-transition="slide" data-direction="reverse">No text</a>
<h1>Plattegrond</h1>
</div>
<div id="map-canvas"></div>
<select id="type" onchange="filterMarkers(this.value);">
<option value="">Please select category</option>
<option value="restaurant">restaurant</option>
<option value="shopping">shopping</option>
<option value="toilet">toilet</option>
</select>
</div>
and here the javascript code: 和这里的JavaScript代码:
$(document).on("pagebeforeshow","#map",function(){
function initialize() {
var center = new google.maps.LatLng(51.458391, 5.391632);
var mapOptions = {
zoom: 18,
center: center,
mapTypeId: 'roadmap',
styles: myStyles
};
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
for (i = 0; i < markers1.length; i++) {
addMarker(markers1[i]);
}
}
// Init map
initialize();
});
Than I stripped the code down and uses the code from the link where I refer to I really don't get it why it is not loading or showing. 比起我将代码剥离下来,并使用我所指的链接中的代码,我真的不明白为什么它没有加载或显示。 I implemented the google api link below my local js at the bottom of html like this:
我在html底部的本地js下面实现了google api链接,如下所示:
<script type="text/javascript" src="js/index.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBZZcdBQRqmJEzM1s3VmBh96Bw4dKQhoAU"></script>
If I run in browser the first time the map is not showing but when I refresh it is showing... Pretty weird but how can I make it show for first time on mobile? 如果我是第一次在浏览器中运行,则地图没有显示,但刷新时却显示了。。。很奇怪,但是如何使它在手机上首次显示呢?
尝试将此CSP meta添加到索引页面或安装白名单插件:
<meta http-equiv="Content-Security-Policy" content="img-src 'self' * default-src * gap://ready file:; style-src 'self' 'unsafe-inline'; 'self' data:; script-src 'self' * 'unsafe-inline' 'unsafe-eval' http://maps.google.com https://maps.google.com http://maps.googleapis.com https://maps.googleapis.com">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.