diff --git a/JS/cities.js b/JS/cities.js index 60490b7..9727882 100644 --- a/JS/cities.js +++ b/JS/cities.js @@ -1,115 +1,135 @@ let cities = [ - "Mumbai", - "Delhi", - "Bangalore", - "Hyderabad", - "Ahmedabad", - "Chennai", - "Kolkata", - "Pune", - "Jaipur", - "Lucknow", - "Kanpur", - "Nagpur", - "Indore", - "Thane", - "Bhopal", - "Visakhapatnam", - "Pimpri-Chinchwad", - "Patna", - "Vadodara", - "Ghaziabad", - "Ludhiana", + "Agartala", "Agra", - "Nashik", - "Faridabad", - "Meerut", - "Rajkot", - "Kalyan-Dombivli", - "Vasai-Virar", - "Varanasi", - "Srinagar", - "Aurangabad", - "Dhanbad", - "Amritsar", - "Navi Mumbai", + "Ahmedabad", + "Aizawl", + "Ajmer", + "Akola", + "Alappuzha", + "Aligarh", "Allahabad", - "Howrah", - "Ranchi", - "Coimbatore", - "Jabalpur", - "Gwalior", - "Vijayawada", - "Jodhpur", - "Madurai", - "Raipur", - "Kota", - "Guwahati", - "Chandigarh", - "Solapur", - "Hubli–Dharwad", - "Mysore", - "Tiruchirappalli", + "Ambala", + "Ambattur", + "Amravati", + "Amritsar", + "Amroha", + "Anand", + "Anantapur", + "Arrah", + "Asansol", + "Aurangabad (Bihar)", + "Aurangabad (Maharashtra)", "Bareilly", - "Aligarh", - "Tiruppur", - "Moradabad", - "Jalandhar", - "Bhubaneswar", - "Salem", - "Warangal", - "Guntur", + "Belgaum", + "Bellary", + "Bhagalpur", + "Bhavnagar", + "Bhilai", "Bhiwandi", - "Saharanpur", - "Gorakhpur", + "Bhiwadi", + "Bhopal", + "Bhubaneswar", "Bikaner", - "Amravati", - "Noida", - "Jamshedpur", - "Bhilai", + "Bilaspur", + "Bokaro Steel City", + "Buxar", + "Chandigarh", + "Chennai", + "Chhapra", + "Coimbatore", "Cuttack", - "Firozabad", - "Kochi", - "Bhavnagar", + "Davanagere", "Dehradun", + "Delhi", + "Dhanbad", + "Dhule", "Durgapur", - "Asansol", - "Nanded", - "Kolhapur", - "Ajmer", + "Faridabad", + "Firozabad", + "Gandhinagar", + "Ghaziabad", + "Gorakhpur", + "Gopalpur", "Gulbarga", - "Jamnagar", - "Ujjain", - "Loni", - "Siliguri", - "Jhansi", - "Ulhasnagar", + "Guntur", + "Gwalior", + "Guwahati", + "Hubli–Dharwad", + "Hyderabad", + "Imphal", + "Indore", + "Jabalpur", + "Jaipur", + "Jalandhar", + "Jalgaon", "Jammu", - "Sangli-Miraj & Kupwad", - "Mangalore", - "Erode", - "Belgaum", - "Kurnool", - "Ambattur", - "Rajahmundry", - "Tirunelveli", - "Malegaon", - "Gaya", - "Udaipur", + "Jamnagar", + "Jamshedpur", + "Jodhpur", + "Jorhat", "Kakinada", - "Davanagere", + "Kalyan-Dombivli", + "Kanpur", + "Karimnagar", + "Kharagpur", + "Kochi", + "Kollam", + "Kolhapur", + "Kolkata", + "Kota", "Kozhikode", - "Akola", "Kurnool", - "Bokaro Steel City", - "Bellary", - "Patiala", - "Gopalpur", - "Agartala", - "Bhagalpur", + "Loni", + "Lucknow", + "Ludhiana", + "Madurai", + "Malegaon", + "Mangalore", + "Meerut", + "Moradabad", + "Mumbai", "Muzaffarnagar", - "Korba", + "Mysore", + "Nagpur", + "Nanded", + "Nashik", + "Navi Mumbai", + "Noida", + "Panipat", + "Patiala", + "Patna", + "Pimpri-Chinchwad", + "Pune", + "Raipur", + "Rajahmundry", + "Rajkot", + "Ranchi", + "Rohtak", + "Saharanpur", + "Salem", + "Sangli-Miraj & Kupwad", + "Shimla", + "Silchar", + "Siliguri", + "Solapur", + "Srinagar", + "Surat", + "Thane", + "Thiruvananthapuram", "Thrissur", - "Aligarh", - "Mangalore" -] \ No newline at end of file + "Tiruchirappalli", + "Tirunelveli", + "Tiruppur", + "Tirupati", + "Udaipur", + "Ujjain", + "Ulhasnagar", + "Vadodara", + "Varanasi", + "Vasai-Virar", + "Vellore", + "Vijayawada", + "Visakhapatnam", + "Warangal", + "Yamunanagar" +]; \ No newline at end of file diff --git a/JS/weatherFind.js b/JS/weatherFind.js index c980340..e5001e1 100644 --- a/JS/weatherFind.js +++ b/JS/weatherFind.js @@ -1,15 +1,21 @@ -if ('geolocation' in navigator) { - navigator.geolocation.getCurrentPosition((position) => { - let lat = position.coords.latitude; - let long = position.coords.longitude; - console.log(lat, long); +function live_location() { + if ('geolocation' in navigator) { + navigator.geolocation.getCurrentPosition((position) => { + let lat = position.coords.latitude; + let long = position.coords.longitude; + console.log(lat, long); + + const URL_Location = `https://api.geoapify.com/v1/geocode/reverse?lat=${lat}&lon=${long}&apiKey=0d7e0434effa4ea3825e16245d95ba24`; + + console.log("Location:-" + URL_Location); + getLoc(URL_Location); + }); + } +}; +live_location(); + - const URL_Location = `https://api.geoapify.com/v1/geocode/reverse?lat=${lat}&lon=${long}&apiKey=0d7e0434effa4ea3825e16245d95ba24`; - console.log("Location:-" + URL_Location); - getLoc(URL_Location); - }); -} let city; @@ -106,6 +112,10 @@ async function weatherAPI(city) { }; function callWeatherApiByButton() { + if (searchCityInHtml.value == "Current Location") { + live_location(); + return; + } cityNameToSearch = searchCityInHtml.value; cityIndiaCheckVar = 0; checkCity(cityNameToSearch) diff --git a/index.html b/index.html index 2320fbc..23c8533 100644 --- a/index.html +++ b/index.html @@ -19,6 +19,7 @@