Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.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
Ionic framework 谷歌地图不显示在使用Cordova的Ionic Android Build.apk上(在Chrome浏览器上运行良好)_Ionic Framework - Fatal编程技术网

Ionic framework 谷歌地图不显示在使用Cordova的Ionic Android Build.apk上(在Chrome浏览器上运行良好)

Ionic framework 谷歌地图不显示在使用Cordova的Ionic Android Build.apk上(在Chrome浏览器上运行良好),ionic-framework,Ionic Framework,Plz帮助 问题:无法在使用cardova的爱奥尼亚安卓构建应用的页面上显示谷歌地图 在没有ANDROID构建的CHROME ie上运行良好 第页: 控制器: .controller('mapPageTabCtrl', function($scope, $timeout, googleAppEngineService, $ionicPopup, controller_Provider, $ionicLoading, $compile) { $scope.init= fun

Plz帮助

问题:无法在使用cardova的爱奥尼亚安卓构建应用的页面上显示谷歌地图 在没有ANDROID构建的CHROME ie上运行良好

第页:

控制器:

.controller('mapPageTabCtrl', function($scope, $timeout, googleAppEngineService, $ionicPopup,  
     controller_Provider, $ionicLoading, $compile) {

    $scope.init= function() 
    {   
        var propAddress = $scope.propInfoDetailsObj.prop_address;
        var geocoder = new google.maps.Geocoder();
        var result = "";
        geocoder.geocode( { 'address': propAddress}, function(results, status) 
        {
             if (status == google.maps.GeocoderStatus.OK) 
             {
                 var myLatlng = new google.maps.LatLng(results[0].geometry.location.lat(), results[0].geometry.location.lng() );

                var mapOptions = {
                  center: myLatlng,
                  zoom: 14,
                  mapTypeId: google.maps.MapTypeId.ROADMAP
                };

                var map = new google.maps.Map(document.getElementById("map"), mapOptions); 

                    var marker = new google.maps.Marker({
                      map: map,
                      position: myLatlng
                    });

                    google.maps.event.addListener(marker, 'click', function() {
                      infowindow.open(map,marker);
                    });

                 $scope.map = map;
             } 
             else 
             {
                 result = "Unable to find address: " + status;
                 console.log("###" + result);
             }

        })//geocoder.geocode( { 'ad
    };  
    //});// function()
})//controller('mapPageTabCtrl',
在android build$ionic build android之前,使用tomcat在Chrome浏览器上进行了测试,效果良好。我可以在页面上看到谷歌地图

其次,, 使用$ionic build android,创建了一个apk文件,并在AVD emulator和真实的android手机上进行了测试,注意页面不会加载google地图,看起来它忽略了$scope.init=function{}


将非常感谢您的帮助…

问题已解决-代码错误,这会阻止加载地图

如果您可以在浏览器上查看地图,但在为android部署时无法查看地图,请运行以下命令:爱奥尼亚插件添加cordova插件白名单。默认情况下禁用Http请求,因此不会加载所有外部脚本。

首先,您应该尝试加载基本映射并检查$scope.init是否正常工作在chrome上调试时,它确实执行了$scope.init函数,这就是为什么我能够在页面上看到googleMap。使用$ionic build android为android生成了相同的代码,当apk在实际的android手机上测试时,它没有在页面上显示googleMap。我现在收到了一个类似的错误,可以在浏览器上运行,但在手机上运行时不会。你是怎么解决的?
.config(function($stateProvider, $urlRouterProvider) {
 $stateProvider
    .state('mapPage', 
     url: '/9',
     templateUrl: 'mapPage.html',
     controller: 'mapPageTabCtrl'
  })
.controller('mapPageTabCtrl', function($scope, $timeout, googleAppEngineService, $ionicPopup,  
     controller_Provider, $ionicLoading, $compile) {

    $scope.init= function() 
    {   
        var propAddress = $scope.propInfoDetailsObj.prop_address;
        var geocoder = new google.maps.Geocoder();
        var result = "";
        geocoder.geocode( { 'address': propAddress}, function(results, status) 
        {
             if (status == google.maps.GeocoderStatus.OK) 
             {
                 var myLatlng = new google.maps.LatLng(results[0].geometry.location.lat(), results[0].geometry.location.lng() );

                var mapOptions = {
                  center: myLatlng,
                  zoom: 14,
                  mapTypeId: google.maps.MapTypeId.ROADMAP
                };

                var map = new google.maps.Map(document.getElementById("map"), mapOptions); 

                    var marker = new google.maps.Marker({
                      map: map,
                      position: myLatlng
                    });

                    google.maps.event.addListener(marker, 'click', function() {
                      infowindow.open(map,marker);
                    });

                 $scope.map = map;
             } 
             else 
             {
                 result = "Unable to find address: " + status;
                 console.log("###" + result);
             }

        })//geocoder.geocode( { 'ad
    };  
    //});// function()
})//controller('mapPageTabCtrl',