这是一个简单的答案,但我不知道该去哪里。我如何使用窗口。代码,我已经在互联网上搜索了几周。我正在尝试实现地理围栏功能,但是我注意到 Cordova 现在使用 window.** 格式。我寻找 Material 来阅读它,但我陷入困境......我正在尝试实现插件 https://github.com/cowbell/cordova-plugin-geofence ,我只能使用以下方法:
- window.geofence.initialize(onSuccess, onError)
- window.geofence.addOrUpdate(geofences, onSuccess, onError)
- window.geofence.remove(geofenceId, onSuccess, onError)
- window.geofence.removeAll(onSuccess, onError)
- window.geofence.getWatched(onSuccess, onError)
在index.js文件中,因为我不知道如何在其他地方实现它们,例如服务......
请帮忙。谢谢。
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js">
if ($window.geofence === undefined) {
$log.warn("Geofence Plugin not found. Using mock instead.");
$window.geofence = window.geofence
$window.TransitionType = window.TransitionType;
}
</script>
最佳答案
您可以从 ngCordova 模块中汲取灵感。 例如 $cordovaGeolocation 服务(或其他服务):
- 原始 Cordova 插件:https://github.com/apache/cordova-plugin-geolocation
- $cordovaGeolocation 文档:http://ngcordova.com/docs/plugins/geolocation/
- $cordovaGeolocation 来源:https://github.com/driftyco/ng-cordova/blob/master/src/plugins/geolocation.js
另请检查此 Ionic 地理围栏示例:https://github.com/cowbell/ionic-geofence
PS:在 cordova-plugin-geolocation 中,插件 API 附加到“navigator”(而不是窗口)。即:navigator.geolocation.getCurrentPosition()
关于javascript - 使用窗口."plugin" Cordova ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34965902/