【问题标题】:Cordova GeoLocation not working in android appCordova GeoLocation 在 android 应用程序中不起作用
【发布时间】:2017-03-08 08:06:21
【问题描述】:

我正在使用 cordova 插件地理定位,在 IONIC Android 应用中获取用户位置 获取位置的代码

$cordovaGeolocation
        .getCurrentPosition()
        .then(function (position) {
          $scope.map.center.lat  = position.coords.latitude;
          $scope.map.center.lng = position.coords.longitude;
          $scope.map.center.zoom = 18;
          $scope.map.markers.now = {
            lat:position.coords.latitude,
            lng:position.coords.longitude,
            focus: true,            
            draggable: false,
            //message: ''
          };

        }

这些代码在 android 移动应用程序中不起作用,调试显示“REQUIRED SSL”

由于应用程序在本地运行,在每个移动设备上,如何使用 ssl 或者是否有任何其他选项可以在混合应用程序中获取用户位置。

【问题讨论】:

  • 你有没有得到解决方案?如果有,请发布答案

标签: angularjs cordova ionic-framework


【解决方案1】:
.controller('MyCtrl', function($scope, $cordovaGeolocation) {
   var posOptions = {timeout: 10000, enableHighAccuracy: false};
   $cordovaGeolocation
   .getCurrentPosition(posOptions)

   .then(function (position) {
      var lat  = position.coords.latitude
      var long = position.coords.longitude
      console.log(lat + '   ' + long)
   }, function(err) {
      console.log(err)
   });

   var watchOptions = {timeout : 3000, enableHighAccuracy: false};
   var watch = $cordovaGeolocation.watchPosition(watchOptions);

   watch.then(
      null,

      function(err) {
         console.log(err)
      },

      function(position) {
         var lat  = position.coords.latitude
         var long = position.coords.longitude
         console.log(lat + '' + long)
      }
   );

   watch.clearWatch();

})

【讨论】:

  • 它只工作了一次,要再次获取位置我必须重新启动应用程序
  • 你得到这个解决方案了吗??如果有,请发布答案
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-12-14
  • 1970-01-01
  • 2017-02-03
  • 2021-02-06
  • 2018-03-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多