Cordova应用程序忽略纹波地理定位设置 [英] Ripple geolocation settings being ignored by Cordova application
问题描述
我使用Visual Studio 2013 Update 4,并且已经安装了Visual Studio for Cordova插件(版本0.3.22015.1)。
我已经创建基于Angular的应用程序,基于科尔多瓦的Ionic SideMenu Starter Template 例。我在config.xml文件中包含了Cordova地理定位插件。
在本例中,我使用以下代码获取设备位置:
$ scope.showPosition =函数(位置){
// ...
}
$ scope.getLocation = function(){
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition($ scope.showPosition,$ scope.showError);
}
else {
$ scope.error =此浏览器不支持地理定位。;
$ / code $ / pre
执行此代码时,我期待的位置传递给showPosition回调的对象具有在Ripple模拟器中指定的模拟地理位置值。然而,我没有得到这些模拟值,我得到了我的实际位置。
如何让我的代码使用模拟值?
解决方案不幸的是,这是Ripple本身的错误。好消息是周三刚刚发布了一个修复程序。 https://github.com/apache/incubator-ripple/blob / master / doc / CHANGELOG.md
您可以打开命令提示符并输入以下内容修改VS 2013中的Ripple:
cd%appdata%\\\
pm\\\
ode_modules\vs-mda
npm install ripple-emulator@0.9.29 --save
对于VS 2015:
cd%appdata%\\\
pm\\\
ode_modules\vs-tac
npm install ripple-emulator@0.9.29 --save
如果清除科尔多瓦缓存,您将需要再次执行此操作。
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?
解决方案 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.
这篇关于Cordova应用程序忽略纹波地理定位设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!