Cordova 应用程序忽略 Ripple 地理定位设置

Ripple geolocation settings being ignored by Cordova application

我正在使用 Visual Studio 2013 Update 4 并且我已经安装了 Visual Studio for Cordova 插件(版本 0.3.22015.1)。

我根据 Ionic SideMenu Starter Template for Cordova 示例创建了一个基于 Angular 的应用程序。我在 config.xml 文件中包含了 Cordova 地理定位插件。

在此示例中,我使用以下代码获取设备的位置:

$scope.showPosition = function (position) {
 // ...
}

$scope.getLocation = function () {
 if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition($scope.showPosition, $scope.showError);
 }
 else {
  $scope.error = "Geolocation is not supported by this browser.";
 }
}

执行此代码时,我希望传递给 showPosition 回调的位置对象具有 Ripple 模拟器中指定的模拟地理位置值。但是我没有得到这些模拟值,我得到了我的实际位置。

如何让我的代码使用模拟值?

不幸的是,这是 Ripple 本身的错误。好消息是周三刚刚发布了一个修复程序。 https://github.com/apache/incubator-ripple/blob/master/doc/CHANGELOG.md

您可以在 VS 2013 中修补 Ripple,方法是打开命令提示符并键入:

cd %appdata%\npm\node_modules\vs-mda
npm install ripple-emulator@0.9.29 --save

对于 VS 2015:

cd %appdata%\npm\node_modules\vs-tac
npm install ripple-emulator@0.9.29 --save

如果清除 Cordova 缓存,您将需要再次执行此操作。