Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Struggling on Getting a User's location

Hi all,

I'm working on a project where I need to get a user's location, and then return the weather for their location using openweathermap's api. I'm just really stuck on where to begin gathering a user's location from, and if there's a right or wrong way to do it. Here is a helpful link I found: http://www.w3schools.com/html/html5_geolocation.asp but I'm not sure how to utilize it. If anyone has any helpful suggestions on using this api with this code, (or other code), I would really appreciate it! Getting a little frustrated.... :) Thanks,

~ Gabriel

1 Answer

Kevin Korte
Kevin Korte
28,149 Points

Here, check out this, it can be as simple as this: https://codepen.io/kevink/pen/zomwMY

Hey thx again Kevin. I completely forgot to reuse the post I sent you before and ask there, but I totally forgot. This project has temporarily addled my brain... :)