Coder Social home page Coder Social logo

f3-march-contest's Introduction

F3-March-Contest

Task The task is to build a web application that fetches a user's geolocation using the Geolocation API, saves the coordinates in localStorage, and displays the location on a map. Your task is to create an HTML file with a button to fetch the user's geolocation and a div to display the map, a JavaScript file to handle the geolocation and map integration, and a CSS file to style the HTML elements.

Requirements Create an HTML file called index.html.This file should have a button with the text "Get Location" and an empty div with an id of map.You should also include a link to your CSS file and a script tag to your JavaScript file.

In your JavaScript file, define a function called getLocation().This function should check if the Geolocation API is supported by the user's browser. If it is, call the getCurrentPosition()method of the Geolocation API, passing in a callback function called showPosition as an argument. If the Geolocation API is not supported, display an error message to the user.

Hint: https://www.w3schools.com/html/html5_geolocation.asp

In the showPosition function, retrieve the user's latitude and longitude from the positionobject passed as an argument. Use the setItem() method of localStorage to save the latitude and longitude in the browser's local storage. You should use the keys latand longto save the latitude and longitude respectively.

Use the Google Maps to display the user's location on a map. To display the lat,long of the user on a map refer to these links -

How to put lat,long on map- https://stackoverflow.com/questions/33464192/display-an-embedded-google-map-iframe-with-a-marker-on-a-certain-latitude-and-lo Video tut - https://drive.google.com/file/d/1pPgAwDs0A8dZMVRQkdEsLE63n6JhYAzV/view?usp=sharing

Create a Remove Location button and once the button is clicked remove the lat and long from the localstorage.

If the lat,long are already there in the localstorage disable the Get Location button as the location has already been fetched earlier and directly show the map

f3-march-contest's People

Contributors

siva9727 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.