如何将IndoorAtlas api与IONIC 1和angular 1整合? 这里Go to documents他们已经展示了与cordova应用程序的集成。
答案 0 :(得分:1)
将整个cordova代码放入angularJS的控制器代码中,如下图所示,并根据需要在前端使用。
angular.module('IndoorMap', [])
.controller('IndoorMapCtrl', ['$scope','$translate', '$rootScope',
function($scope, $translate, $rootScope) {
$scope.startPositioning = function() {
cordovaExample.startPositioning();
};
$scope.stopPositioning = function() {
cordovaExample.stopPositioning();
};
var cordovaExample = {
watchId: null,
regionWatchId: null,
marker: null,
retina: window.devicePixelRatio > 1 ? true : false,
// Starts positioning the user in the given floorplan area
startPositioning: function() {
SpinnerPlugin.activityStart('Move around to get a location');
if (this.watchId != null) {
IndoorAtlas.clearWatch(this.watchId);
}
this.watchId = IndoorAtlas.watchPosition(this.showLocation,
this.IAServiceFailed);
cordovaExample.startRegionWatch();
},
// Stops positioning the user
stopPositioning: function() {
IndoorAtlas.clearWatch(this.watchId);
cordovaExample.stopRegionWatch();
alert("IndoorAtlas positioning stopped");
}
.config(['$stateProvider', '$translateProvider', function($stateProvider, $translateProvider) {
$stateProvider
.state('indoorMap', {
url: '/indoorMap',
parent: 'menu',
cache: false,
views: {
'appContent': {
templateUrl: 'view/IndoorAtlasView/indoorAtlasMap.html',
controller: 'IndoorMapCtrl'
}
},
});
}]);