How To Get a User's Location With JavaScript (Geolocation API Tutorial)

preview_player
Показать описание
In this tutorial, you'll learn how to get a user's location with JavaScript.

We can request the user's location with JavaScript using the GeoLocation API, which is available in most modern browsers, and it gives us a function to call which will help us determine the user's location with JavaScript.

Getting the user's location in JavaScript is pretty simple and we'll break this JavaScript tutorial down into working with the JavaScript GeoLocation API and how to convert latitude and longitude to address.

In the video we'll take a look at the JavaScript GeoLocation API and how it can be used to get the user's location with JavaScript. Of course the user needs to provide consent to your website / App to find their location but if they do you'll get a longitude and latitude value back which approximately represents where the user is located.

The second part of this JavaScript tutorial will focus on parsing the date from the JavaScript GeoLocation API in to a textual representation of the user's address. In order to do this we'll need to use a 3rd party API to convert our longitude and latitude data in to an actual address.

So hopefully you'll see in this JavaScript tutorial how to get a user's location with JavaScript (or how to get a users location with JavaScript) using Geolocation or more specifically with a Geolocation HTML5 tutorial making this a useful addition as a 'location with JavaScript' tutorial to the JavaScript HowTos series.

Don't forget to check out some of the other JavaScript HowTos here on the Junior Developer Central channel for some more excellent JavaScript tutorial for beginners.

#JavaScript #JavaScriptHowtos #Geolocation Channel Handle @codebubb
Рекомендации по теме
Комментарии
Автор

man where have u being with the short lesson you make my day

bongbuincyril
Автор

I just don't understand why I can't just grab the string?? I mean in the result I can see I've managed to grab just the city name and I want to store it in a variable so I could use it but it doesn't work 😞 can someone show the best practice to store the object as a string so I could use it to concatenate with the project I want to use pls 😭

KeepLearing
Автор

Thanks a lot.... Keep doing the good work.

wzard-dx
Автор

Hai, good video, and also I want to get user's exact correct location without SSL in my website, how to do it

yaseenimuhammadraja
Автор

This is exactly what I was looking for. Thanks. I've tried to figure out why my array is coming back empty. Any ideas?

mxurbano
Автор

How would i store this type of info inside a variable?

ABunchaHerbs
Автор

First of all: thanks for that tutorial. Like Christophe, my results array is also empty. What I did was this:

const successfulLookup = (position) => {
const { latitude, longitude } = position.coords;
.then(response => response.json())
.then(console.log);
};
navigator.geolocation.getCurrentPosition(successfulLookup, console.log);

It seems that it has no access to the coordinates. Do you have any hint for me? Thanks in advance

techpuzzle
Автор

In the JavaScript can I find passwords or any stuff just a question

bankai
Автор

guys make sure the link you copied is in query format.. for some reason the site changed it

randomactivities
Автор

Gorsly Piece, Quinton, United Kingdom

therealbrucewayne
Автор

Why this show to me Letonia, Europe?, I'm in latinoamerica (((

genaro
Автор

for some reason I'm getting a JSON.parse() error

codesenpai
Автор

i get error, "response is undefined"

makotodaiwaambara
Автор

Jesus is King! If you do not know Jesus as Savior please pray, “ Jesus save me. At this moment I choose to have faith that You gave Your life for me and rose from the dead. Doing this You defeated death, even though it meant You had to die. You surrendered Your life for me, so I chose to surrender my life to You. Forgive me Jesus, my God. Amen.”

Jesus loves you so much. Please accept His love. I encourage you to read the Bible and pray.

“For God so loved the world that he gave his one and only begotten only Son into this world, that whoever believes that in him shall not perish but have eternal life.”
John 3:16

🙏❤️🙏

Jesus is enough!

Again I tell you, Jesus loves you!

harpermartin
Автор

Jesus is King! If you do not know Jesus as Savior please pray, “ Jesus save me. At this moment I choose to have faith that You gave Your life for me and rose from the dead. Doing this You defeated death, even though it meant You had to die. You surrendered Your life for me, so I chose to surrender my life to You. Forgive me Jesus, my God. Amen.”

Jesus loves you so much. Please accept His love. I encourage you to read the Bible and pray.

“For God so loved the world that he gave his one and only begotten only Son into this world, that whoever believes that in him shall not perish but have eternal life.”
John 3:16

🙏❤️🙏

Jesus is enough!

Again I tell you, Jesus loves you!

harpermartin
join shbcf.ru