Header Ads

Geo location Using JavaScript

Geo Location Using JavaScript

Geolocation may be used in weather apps to access the user's location and show the weather of the place where the user lives.

The Code to do this is below



Code :

if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(function (position){
const pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};

const map = new google.maps.Map(document.getElementById('map'), {
zoom: 8,
center: pos
});

const marker = new google.maps.Marker({
position: pos,
map: map
});
});
} else{
console.log("Geolocation not supported");
}










Related Links:




Services:

Post a Comment

0 Comments