即时通讯使用phonegap来构建我的应用程序,当我试图在主页面打开应用程序和海洋地图时,我得到灰色封面而不是android中的地图。 当我用铬打开它时,我可以将地图打开。
附加代码:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="default-src *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; style-src 'self' 'unsafe-inline' *; img-src * data: 'unsafe-inline'">
<meta name="viewport" content="width=device-width, height= device-height, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="css/mainCSS.css">
<link rel="stylesheet" href="css/sideAndUpperMenuCSS.css">
<link href='http://serve.fontsproject.com/css?family=Felix007:400' rel='stylesheet' type='text/css'>
<script src="js/mainScript.js"></script>
<script src="js/sideAndUpperMenuScript.js"></script>
<script src="js/jquery-2.0.3.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css">
</head>
<body>
<div id="mySidenav" class="sidenav">
</div>
<div id="floating-panel">
<button class="icon" id="submit"></button>
<input type="text" align="right" id="address" placeholder="חיפוש כתובת" />
</div>
<div id="map"></div>
<span id="requestPointZone">
<button class="btn btn-info btn-block bigButton" onclick="changeButtons()" id="choiceList">הזמן נקודת מכירה</button>
</span>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyADlk_CtGRjQOGs3fk8NjG9yVQwj4xPxnI&callback=initMap">
</script>
</body>
</html>
js file:
function geocodeAddress(resultsMap, geocoder) {
var address = document.getElementById('address').value;
geocoder.geocode({'address': address}, function(results, status) {
if (status === 'OK') {
resultsMap.setZoom(15);
resultsMap.setCenter(results[0].geometry.location);
}
});
}
function onSuccess(position) {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 15,
center: {lat: position.coords.latitude , lng: position.coords.longitude},
mapTypeControl: false
});
initPage(map);
}
function onError(error) {
alert('code: ' + error.code + '\n' + 'message: ' + error.message + '\n');
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 15,
center: {lat: 32.080633 , lng: 34.789022},
mapTypeControl: false
});
initPage(map);
}
function initPage(map){
$.ajax({
url: "http://localhost:8080/APPserver/clientServlet",
data: {requestType :"mainMarkers"},
success: function(location) {
for(var i=0; i<location.length; i++) {
var coords = location[i].split("-");
var latLng = new google.maps.LatLng(coords[0], coords[1]);
var marker = new google.maps.Marker({
id: location[i],
position: latLng,
map: map
});
google.maps.event.addListener(marker, 'click', function() {
if (this.getAnimation() != null) {
this.setAnimation(null);
} else {
this.setAnimation(google.maps.Animation.BOUNCE);
}
marker = this.id;
setTimeout(function () {
window.location.href = "salePoint.html"+ "?id=" + marker;
}, 900)
});
}
},
error: function(lo){ console.log("error" + lo.message);}
var geocoder = new google.maps.Geocoder();
);
}
function initMap() {
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
config.xml文件也包含以下行:
</platform>
<feature name="Geolocation">
<param name="ios-package" value="CDVLocation" />
</feature>
<feature name="Geolocation">
<param name="android-package" value="org.apache.cordova.geolocation.GeoBroker" />
</feature>
<access origin="*" />
<allow-navigation href="http://*/*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<config-file platform="ios" target="*-Info.plist" parent="LSApplicationQueriesSchemes">
<array>
<string>waze</string>
</array>
</config-file>
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<gap:plugin name="phonegap-facebook-plugin" version="0.12.0">
<param name="APP_ID" value="1901343470147655" />
<param name="APP_NAME" value="FarmobileApp" />
</gap:plugin>
<access origin="geo:*" launch-external="yes"/>
我添加了这一行:
正如我在phonegap的日志文件中看到的那样,但仍然存在同样的问题。任何想法?
谢谢!
答案 0 :(得分:0)
好的问题是这一行: navigator.geolocation.getCurrentPosition(onSuccess,onError);
一旦我对它发表评论就行了。