【发布时间】:2016-08-30 13:40:30
【问题描述】:
我的 Google 地图在 Firefox 中运行良好,但是当我为移动设备构建它时。该地图根本不显示或加载,遗憾的是我的编码经验和知识是zilch并且仍然没有找到解决方案......有没有人有任何关于问题的指针?如果需要,我可以发布更多代码
var map, places, iw;
var markers = [];
var autocomplete;
var defaultLatLng = new google.maps.LatLng(34.0983425, -118.3267434);
var myLatlng = new google.maps.LatLng(37.783259, -122.402708);
function initialize() {
var myOptions = {
zoom: 17,
//center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
if (navigator.geolocation) {
browserSupportFlag = true;
navigator.geolocation.getCurrentPosition(function(position) {
initialLocation = new google.maps.LatLng(position.coords
.latitude, position.coords.longitude);
map.setCenter(initialLocation);
map.setZoom(16);
var marker = new google.maps.Marker({
position: initialLocation,
title: "You are here!"
});
marker.setMap(map);
}, function() {
handleNoGeolocation(browserSupportFlag);
});
}
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
places = new google.maps.places.PlacesService(map);
google.maps.event.addListener(map, 'tilesloaded', tilesLoaded);
autocomplete = new google.maps.places.Autocomplete(document.getElementById(
'autocomplete'));
google.maps.event.addListener(autocomplete, 'place_changed', function() {
showSelectedPlace();
});
}
【问题讨论】:
-
听起来你好像没有在你的
config.xml文件中将它列入白名单。尝试将此添加到配置中...<access origin="*"/>这将使您的应用程序可以访问外部资源。我建议将原始部分配置为更具体的内容。确保您也添加了 cordova 白名单插件,请参阅 Github 文档...github.com/apache/…
标签: javascript android google-maps phonegap-plugins phonegap-build