Skip to content

Commit 9c07a33

Browse files
committed
Changed condition and geocoordinates
1 parent d0d92fe commit 9c07a33

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ yarn-error.log*
3333

3434
# vercel
3535
.vercel
36+
.idea

pages/api/offers.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,31 @@ export default (req, res) => {
88

99
const citiesCoords = {
1010
mumbai: {
11-
lat: 20,
12-
lon: 78
11+
lat: 19,
12+
lon: 72
1313
},
1414
london: {
15-
lat: 55,
16-
lon: -3
15+
lat: 51,
16+
lon: 0
1717
},
1818
"san francisco": {
1919
lat: 37,
20-
lon: -95
20+
lon: -122
2121
},
2222
singapore: {
2323
lat: 1,
2424
lon: 103
2525
},
2626
sydney: {
27-
lat: -31,
28-
lon: 115
27+
lat: -33,
28+
lon: 151
2929
}
3030
}
3131
const citiesKeys = Object.keys(citiesCoords);
3232
citiesKeys.forEach((cityName) => {
3333
const cityCoords = citiesCoords[cityName];
34-
const hasMatchingLat = latitude >= cityCoords.lat - 3 || latitude <= cityCoords.lat + 3;
35-
const hasMatchingLon = longitude >= cityCoords.lon - 3 || longitude <= cityCoords.lon + 3;
34+
const hasMatchingLat = latitude >= cityCoords.lat - 3 && latitude <= cityCoords.lat + 3;
35+
const hasMatchingLon = longitude >= cityCoords.lon - 3 && longitude <= cityCoords.lon + 3;
3636
if(hasMatchingLat && hasMatchingLon) {
3737
city = cityName;
3838
}

0 commit comments

Comments
 (0)