1
1
module . exports = {
2
2
3
- getLocation : function ( callback , callback2 ) {
3
+ getLocation : function ( callback , callback2 ) {
4
4
if ( navigator . geolocation ) {
5
- navigator . geolocation . getCurrentPosition ( callback ) ;
6
- navigator . geolocation . getCurrentPosition ( callback2 ) ;
5
+ debugger ;
6
+ navigator . geolocation . getCurrentPosition ( callback , function ( error ) {
7
+ console . log ( error ) ;
8
+ } , { maximumAge : Infinity , enableHighAccuracy : true , timeout : 10000 } ) ;
9
+ navigator . geolocation . getCurrentPosition ( callback2 , function ( error ) {
10
+ console . log ( error ) ;
11
+ } , { maximumAge : Infinity , enableHighAccuracy : true , timeout : 10000 } ) ;
7
12
} else {
8
13
alert ( "Geolocation is not supported by this browser." ) ;
9
14
}
10
15
} ,
11
16
12
- getShops : function ( position , callback ) {
17
+ getShops : function ( position , callback ) {
13
18
var currentLocation = new google . maps . LatLng ( position . coords . latitude , position . coords . longitude ) ;
14
19
15
20
// Specify location, radius and place types for your Places API search.
@@ -22,33 +27,33 @@ module.exports = {
22
27
// Handle the callback with an anonymous function.
23
28
var service = new google . maps . places . PlacesService ( map ) ;
24
29
25
- service . nearbySearch ( request , function ( results , status ) {
30
+ service . nearbySearch ( request , function ( results , status ) {
26
31
if ( status == google . maps . places . PlacesServiceStatus . OK ) {
27
32
callback ( results ) ;
28
33
}
29
34
} ) ;
30
35
} ,
31
36
32
- getDetails : function ( placeId , callback ) {
37
+ getDetails : function ( placeId , callback ) {
33
38
var service = new google . maps . places . PlacesService ( map ) ;
34
39
35
40
service . getDetails ( {
36
41
placeId : placeId
37
- } , function ( place , status ) {
38
- if ( status === google . maps . places . PlacesServiceStatus . OK ) {
39
- callback ( place ) ;
40
- }
42
+ } , function ( place , status ) {
43
+ if ( status === google . maps . places . PlacesServiceStatus . OK ) {
44
+ callback ( place ) ;
45
+ }
41
46
} ) ;
42
47
} ,
43
48
44
- calculateTravelTime : function ( userLocation , selectedShopLocation , methodOfTrans , callback ) {
49
+ calculateTravelTime : function ( userLocation , selectedShopLocation , methodOfTrans , callback ) {
45
50
var bounds = new google . maps . LatLngBounds ;
46
51
47
52
var origin1 = userLocation ;
48
53
var destinationA = selectedShopLocation ;
49
54
var methodOfTrans ;
50
55
51
- switch ( methodOfTrans ) {
56
+ switch ( methodOfTrans ) {
52
57
case 'walking' :
53
58
methodOfTrans = google . maps . TravelMode . WALKING ;
54
59
break ;
@@ -71,14 +76,14 @@ module.exports = {
71
76
unitSystem : google . maps . UnitSystem . IMPERIAL ,
72
77
avoidHighways : false ,
73
78
avoidTolls : false
74
- } , function ( response , status ) {
79
+ } , function ( response , status ) {
75
80
if ( status !== google . maps . DistanceMatrixStatus . OK ) {
76
81
alert ( 'Error was: ' + status ) ;
77
82
} else {
78
83
var originList = response . originAddresses ;
79
84
var destinationList = response . destinationAddresses ;
80
- callback ( response ) ;
81
- }
82
- } ) ;
85
+ callback ( response ) ;
86
+ }
87
+ } ) ;
83
88
}
84
89
}
0 commit comments