Skip to content

Commit cbc56ba

Browse files
authored
Merge pull request amituuush#10 from amituuush/geolocation-fix
Geolocation fix
2 parents 0a46c58 + 0e9dcb3 commit cbc56ba

File tree

13 files changed

+2143
-290
lines changed

13 files changed

+2143
-290
lines changed

app/methods/create.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
var Orders = require('../models/orders');
22

3-
var create = function(order, callback) {
4-
Orders.create(order, function(err, result) {
3+
var create = function (order, callback) {
4+
Orders.create(order, function (err, result) {
55
if (err || !order) {
66
console.error("Could not create order", order);
7-
console.log(err);
7+
console.log('err', err);
88
return;
99
}
1010
callback(null, result);

business-admin/components/BusinessAdminView/BAOrder/BAOrder.jsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ var BAOrder = React.createClass({
3232
},
3333

3434

35-
_handleCompleteOrder: function() {
35+
_handleCompleteOrder: function () {
3636
console.log('completing order');
3737
this.props.completeOrder(this.props.order._id);
3838
},
3939

40-
render: function() {
40+
render: function () {
4141

4242
var orderDetails = this.props.order.items.map(
43-
function(item, i) {
43+
function (item, i) {
4444
return <BAOrderDetails
45-
key={i}
46-
item={item} />
47-
});
45+
key={i}
46+
item={item} />
47+
});
4848

4949
if (this.props.order.specialInstructions) {
5050
var specialInstructions = <div className="special-instructions">"{this.props.order.specialInstructions}"</div>
@@ -59,11 +59,12 @@ var BAOrder = React.createClass({
5959
{specialInstructions}
6060
</div>
6161
<div className="ba-order-right">
62-
<Timer
62+
{ /*<Timer
6363
secondsUntilArrival={this.props.order.secondsUntilArrival}
6464
timeSelectedForPickup={this.props.order.timeSelectedForPickup}
6565
expectedPickupTime={this.props.order.expectedPickupTime} />
6666
<p>ETA:</p>
67+
*/ }
6768
<button onClick={this._handleCompleteOrder}>
6869
Complete
6970
<i className="fa fa-check-circle fa-2x" aria-hidden="true"></i>

customer/api.es6

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
module.exports = {
22

3-
getLocation: function(callback, callback2) {
3+
getLocation: function (callback, callback2) {
44
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 });
712
} else {
813
alert("Geolocation is not supported by this browser.");
914
}
1015
},
1116

12-
getShops: function(position, callback) {
17+
getShops: function (position, callback) {
1318
var currentLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
1419

1520
// Specify location, radius and place types for your Places API search.
@@ -22,33 +27,33 @@ module.exports = {
2227
// Handle the callback with an anonymous function.
2328
var service = new google.maps.places.PlacesService(map);
2429

25-
service.nearbySearch(request, function(results, status) {
30+
service.nearbySearch(request, function (results, status) {
2631
if (status == google.maps.places.PlacesServiceStatus.OK) {
2732
callback(results);
2833
}
2934
});
3035
},
3136

32-
getDetails: function(placeId, callback) {
37+
getDetails: function (placeId, callback) {
3338
var service = new google.maps.places.PlacesService(map);
3439

3540
service.getDetails({
3641
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+
}
4146
});
4247
},
4348

44-
calculateTravelTime: function(userLocation, selectedShopLocation, methodOfTrans, callback) {
49+
calculateTravelTime: function (userLocation, selectedShopLocation, methodOfTrans, callback) {
4550
var bounds = new google.maps.LatLngBounds;
4651

4752
var origin1 = userLocation;
4853
var destinationA = selectedShopLocation;
4954
var methodOfTrans;
5055

51-
switch(methodOfTrans) {
56+
switch (methodOfTrans) {
5257
case 'walking':
5358
methodOfTrans = google.maps.TravelMode.WALKING;
5459
break;
@@ -71,14 +76,14 @@ module.exports = {
7176
unitSystem: google.maps.UnitSystem.IMPERIAL,
7277
avoidHighways: false,
7378
avoidTolls: false
74-
}, function(response, status) {
79+
}, function (response, status) {
7580
if (status !== google.maps.DistanceMatrixStatus.OK) {
7681
alert('Error was: ' + status);
7782
} else {
7883
var originList = response.originAddresses;
7984
var destinationList = response.destinationAddresses;
80-
callback(response);
81-
}
82-
});
85+
callback(response);
86+
}
87+
});
8388
}
8489
}

0 commit comments

Comments
 (0)