问题
I'm using Visual Studio 2013 Update 4 and I've installed the Visual Studio for Cordova add-on (version 0.3.22015.1).
I have created an Angular based app based on the Ionic SideMenu Starter Template for Cordova example. I have included the Cordova geolocation plugin in the config.xml file.
Within this example I am obtaining the device's location using the following code:
$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.";
}
}
When this code is executed I'm expecting the position object passed to the showPosition callback to have the mock geolocation values specified in the Ripple emulator. However I don't get these mock values, I get my actual position.
How can I get my code to use the mock values?
回答1:
Unfortunately this was a bug with Ripple itself. The good news is a fix was just released on Wednesday. https://github.com/apache/incubator-ripple/blob/master/doc/CHANGELOG.md
You can patch Ripple in VS 2013 by opening the command command prompt and typing:
cd %appdata%\npm\node_modules\vs-mda
npm install ripple-emulator@0.9.29 --save
For VS 2015:
cd %appdata%\npm\node_modules\vs-tac
npm install ripple-emulator@0.9.29 --save
You will need to do this again if you clear the Cordova Cache.
来源:https://stackoverflow.com/questions/29859372/ripple-geolocation-settings-being-ignored-by-cordova-application