Cordova 地理定位插件有时不工作
Cordova geolocation plugin not working sometimes
我正在 android 上开发一个应用程序,它在很大程度上依赖于 gps 插件的功能,但是在调用 2 次 gps 后,它就停止工作了。我需要打开 google 个地图才能使插件再次工作。
我正在测试三星 J1 和华为 G5 (android 5.1.1)、cordova v7.0.0 和地理定位插件版本 2.4.2
我在另一个问题中找到了答案,查看一下here
感谢 user2147549,所有功劳归于他。
这就是我的情况:
在cordova v5.3.3上,你需要这样做:
1、cordova插件移除cordova-plugin-geolocation
2、cordova插件添加cordova-plugin-geolocation
3、将插件目录中的cordova-plugin-geolocation目录复制到e:\
4、编辑 plugin.xml ,添加:
<js-module src="www/Coordinates.js" name="Coordinates">
<clobbers target="Coordinates" />
</js-module>
<js-module src="www/PositionError.js" name="PositionError">
<clobbers target="PositionError" />
</js-module>
<js-module src="www/Position.js" name="Position">
<clobbers target="Position" />
</js-module>
<js-module src="www/geolocation.js" name="geolocation">
<clobbers target="navigator.geolocation" />
</js-module>
<config-file target="res/xml/config.xml" parent="/*">
<feature name="Geolocation">
<param name="android-package" value="org.apache.cordova.geolocation.GeoBroker"/>
</feature>
</config-file>
<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
</config-file>
5、cordova插件移除cordova-plugin-geolocation
6、cordova插件添加e:\cordova-plugin-geolocation
7、cordova 运行 android 现在,我的gps定位很好。感谢吴仲华
事实证明,这个问题可以通过使用旧版本的插件来解决。
就我而言,我只需要 cordova 应用程序即可在 android 上工作,所以这不是问题。
您需要像这样将 gps 插件添加到您的项目中:
cordova plugin add org.apache.cordova.geolocation@0.3.6
我正在 android 上开发一个应用程序,它在很大程度上依赖于 gps 插件的功能,但是在调用 2 次 gps 后,它就停止工作了。我需要打开 google 个地图才能使插件再次工作。
我正在测试三星 J1 和华为 G5 (android 5.1.1)、cordova v7.0.0 和地理定位插件版本 2.4.2
我在另一个问题中找到了答案,查看一下here
感谢 user2147549,所有功劳归于他。
这就是我的情况:
在cordova v5.3.3上,你需要这样做:
1、cordova插件移除cordova-plugin-geolocation
2、cordova插件添加cordova-plugin-geolocation
3、将插件目录中的cordova-plugin-geolocation目录复制到e:\
4、编辑 plugin.xml ,添加:
<js-module src="www/Coordinates.js" name="Coordinates">
<clobbers target="Coordinates" />
</js-module>
<js-module src="www/PositionError.js" name="PositionError">
<clobbers target="PositionError" />
</js-module>
<js-module src="www/Position.js" name="Position">
<clobbers target="Position" />
</js-module>
<js-module src="www/geolocation.js" name="geolocation">
<clobbers target="navigator.geolocation" />
</js-module>
<config-file target="res/xml/config.xml" parent="/*">
<feature name="Geolocation">
<param name="android-package" value="org.apache.cordova.geolocation.GeoBroker"/>
</feature>
</config-file>
<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
</config-file>
5、cordova插件移除cordova-plugin-geolocation
6、cordova插件添加e:\cordova-plugin-geolocation
7、cordova 运行 android 现在,我的gps定位很好。感谢吴仲华
事实证明,这个问题可以通过使用旧版本的插件来解决。
就我而言,我只需要 cordova 应用程序即可在 android 上工作,所以这不是问题。
您需要像这样将 gps 插件添加到您的项目中:
cordova plugin add org.apache.cordova.geolocation@0.3.6