Wht is HTML geo locatiuon and how to use the same

The Eduladder is a community of students, teachers, and programmers just interested to make you pass any exams. So we solve previous year question papers for you.
See Our team
Wondering how we keep quality?
Got unsolved questions?

Ask Questions

HTML-->View question

Wht is HTML geo locatiuon and how to use the same?

what is HTML Geolocation and how HTML Geolocation API is used to get the geographical position of a user.

Asked by:Jhon

Taged users:

Be first to like this question

Be first to dislike this question
Talk about this  Delete  Like  Dislike


The HTML Geolocation API is used to get the geographical position of a user.

Since this can compromise user privacy, the position is not available unless the user approves it.

Using HTML Geolocation

Use the getCurrentPosition() method to get the user's position.

The example below is a simple Geolocation example returning the latitude and longitude of the user's position:

var x = document.getElementById("demo");
function getLocation() {
    if (navigator.geolocation) {
    } else {
        x.innerHTML = "Geolocation is not supported by this browser.";
function showPosition(position) {
    x.innerHTML = "Latitude: " + position.coords.latitude +
    "<br>Longitude: " + position.coords.longitude;

Example explained:

  • Check if Geolocation is supported
  • If supported, run the getCurrentPosition() method. If not, display a message to the user
  • If the getCurrentPosition() method is successful, it returns a coordinates object to the function specified in the parameter ( showPosition )
  • The showPosition() function gets the displays the Latitude and Longitude
The example above is a very basic Geolocation script

Answerd By:Jeeva

Be first to like this answer

Be first to dislike this answer
Talk about this  Delete  Like  Dislike

Can you help us to add better answer here? Please see this

Below are some of the videos from our collection.Check out our video platform here.

Lets together make the web is a better place

We made eduladder by keeping the ideology of building a supermarket of all the educational material available under one roof. We are doing it with the help of individual contributors like you, interns and employees. So the resources you are looking for can be easily available and accessible also with the freedom of remix reuse and reshare our content under the terms of creative commons license with attribution required close.

You can also contribute to our vision of "Helping student to pass any exams" with these.
Answer a question: You can answer the questions not yet answered in eduladder.How to answer a question
Career: Work or do your internship with us.Work with us
Create a video: You can teach anything and everything each video should be less than five minutes should cover the idea less than five min.How to upload a video on eduladder

Not the answer you're looking for? Browse other questions from this Question paper or ask your own question.

Ask your question?