Need help with Local weather Project

Hey there, new here, I am having trouble with the local weather app for the front-end development certificate.


That’s the url. At first I thought I was pretty much finished besides styling it, but yesterday I went to a friends house and decided to check up on it, when I was there, it didn’t display the city, my friend lives in a different city than I do. However when I am home it displays it correctly. I realize that it’s not accurate enough. is there any way to make it more accurate? I’m assuming that I should use a different url for my plug in, but I won’t be able to tell if it’s accurate or not because I am in an area where it was already accurate. so it’s hard to tell unless I drive somewhere to a different city I guess. Also it does ask for my location but the city, state, and country is already shown before it does, which confuses me, it displays the temperature for the location once I give it permission however, so that is working just fine.

I realize my code is disorganized I apologize, still pretty new to programming I just tried a lot of different methods until they work, basically the information I need help on is just on the html section.

Looking good so far! It was accurate for me from Amarillo, TX. I see that you are using an IP based solution for getting location. What this means is that there are many reasons for the location to be inaccurate. The person could be routing through a VPN, or their ISP could be piggybacking off of a larger network in a nearby city. You may consider using a different API, such as google maps to get more accurate location data. You can take a look at my codepen if you want to get an idea for how to use the google maps API. The code is also a bit messy, haven’t gone back to clean it up yet

ahh ok so basically the reason for the inaccurate info was because of the fact that I used an ip based solution, the thought did not even occur, alright I’ll try to use google maps. I really appreciate the info and the help there.

First of all, the user’s browser must have location services allowed or turned on. Otherwise, geoip location fails and the town/city cant be determined.

Second, GeoIP Location isn’t 100% accurate. It’s not a GPS receiver.

Rather, It’s a best guesstimate on where the user is located based on his IP address.

Now, the user’s IP address is sometimes issued by the user’s Internet Provider that is located several miles away, or even in the next town. Thus performing a geolocation based on the user’s IP address will give the location of the Service Provider, rather than your home/address.

UPDATE: Oops, I was too late submitting this post. @kenbonilla got your answer.

Regardless I still appreciate your input there owel. I didn’t put much thought on how the api can differ depending on which one you decide to use.
I’m going to try to implement kenbonilla’s advice and try to use google maps instead for the location. Thank you both!

Yes, using Google Maps is more accurate… kinda creepy in a way :slight_smile:

Here’s my weather app using Google Maps, see if your reported location is more accurate. Using your program, it positioned me more than 10 miles away.

https://randomquote-owel.surge.sh/

I see what you mean by creepy, the last letter of the city name is basically where I am at. Very impressive work by the way.

If geolocation is deactivated, not supported or the user don’t approve it, the app should provide a fallback to get the user geolocation.

Most of ip based geolocation services out here, do not provide unlimited requests and access through https needs a premium account premium.

GEO-IP provide a free an unlimited api to get the user geolocation based on the ip address and requests are made through https.