使用Phonegap Build后,Google地图不会在手机上显示

时间:2016-05-04 22:36:34

标签: javascript android google-maps phonegap-plugins phonegap-build

我的Google地图在Firefox中运行良好,但是当我为移动设备构建它时。地图根本无法显示或加载,遗憾的是我的编码经验和知识仍然没有找到解决方案......有没有人对问题是什么有任何指示?如果需要,我可以发布更多代码

sift = cv2.xfeatures2d.SIFT_create()

2 个答案:

答案 0 :(得分:0)

你需要使用"插件"在初始化之前

ie:plugin.google.maps.Map(document.getElementById(" map_canvas");

与其他初始化相似

var map, places, iw;
var markers = [];
var autocomplete;
var defaultLatLng = new plugin.google.maps.LatLng(34.0983425, -118.3267434); 
var myLatlng = new plugin.google.maps.LatLng(37.783259, -122.402708);

function initialize() {
  var myOptions = {
    zoom: 17,
    //center: myLatlng,
    mapTypeId: plugin.google.maps.MapTypeId.ROADMAP
  }
  if (navigator.geolocation) {
    browserSupportFlag = true;
    navigator.geolocation.getCurrentPosition(function(position) {
      initialLocation = new plugin.google.maps.LatLng(position.coords
        .latitude, position.coords.longitude);
      map.setCenter(initialLocation);
  map.setZoom(16);
  var marker = new plugin.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);
  plugin.google.maps.event.addListener(map, 'tilesloaded', tilesLoaded);
  autocomplete = new         plugin.google.maps.places.Autocomplete(document.getElementById(
'autocomplete'));
  plugin.google.maps.event.addListener(autocomplete, 'place_changed', function() {
showSelectedPlace();
  });
}

答案 1 :(得分:0)

至少

  1. var defaultLatLng = new google.maps.LatLng(34.0983425,-118.3267434); var myLatlng = new google.maps.LatLng(37.783259,-122.402708);

  2. 应放在initialize()

    1. center:myLatlng

    2. 不应该被注释掉

      1. 应该有以下css样式

        html,body {     身高:100%; }

        map {

        height: 100%;
        

        }