-
Notifications
You must be signed in to change notification settings - Fork 0
/
geoimplementation.js
99 lines (91 loc) · 2.27 KB
/
geoimplementation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
'use strict';
angular.module('geoImplementation',['geoService'])
.directive('geoDirective',['geoService', function (geoService){
return {
templateUrl: 'geodirective.tpl.html',
link: function ($scope,$element,$attr){
$scope.clearResponses = function(){
$scope.responses.splice(0);
},
$scope.changeTrack = function(){
geoService.clearWatch();
$scope.clearResponses();
geoService.watchPosition($scope.track, $scope.options)
.then(function(obj){
//console.log('success');
geoService.clearWatch();
$scope.clearResponses();
$scope.responses.push(angular.copy(obj));
},function(obj){
//console.log('error');
geoService.clearWatch();
$scope.clearResponses();
$scope.responses.push(angular.copy(obj));
},function(obj){
if(obj.code && obj.code === 1)
alert('you must allow geolocation');
//console.log('notify');
$scope.responses.push(angular.copy(obj));
});
};
$scope.stopTrack = function(){
geoService.clearWatch();
};
//$scope.changeTrack();
}
};
}])
.controller('geoController',['$scope', 'watchOptions', function($scope, watchOptions){
angular.extend($scope,{
responses : [],
options: angular.extend({},watchOptions),
track: true
});
}])
.filter('coordName', [function(){
return function(input){
switch(input){
case "accuracy":
return "Accuracy";
break;
case "altitude":
return "Altitude";
break;
case "altitudeAccuracy":
return "Altitude Accuracy";
break;
case "heading":
return "Heading";
break;
case "latitude":
return "Latitude";
break;
case "longitude":
return "Longitude";
break;
case "speed":
return "Speed";
break;
default:
return input;
}
};
}])
.filter('emptyVal', [function(){
return function(input){
switch(input){
case null:
case undefined:
case "":
return "N/A";
break;
default:
return input;
}
};
}])
.value('watchOptions',{
enableHighAccuracy: true,
timeout: 500,
maximumAge: 500
});