Gmaps.js with refresh location button

Developer
Size
2,293 Kb
Views
22,264

How do I make an gmaps.js with refresh location button?

What is a gmaps.js with refresh location button? How do you make a gmaps.js with refresh location button? This script and codes were developed by Gabriel on 12 August 2022, Friday.

Gmaps.js with refresh location button Previews

Gmaps.js with refresh location button - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>gmaps.js with refresh location button</title> <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCIUs5TE6uZAkb4H52mTg-C-ob0OJmc--A"></script>	<script src="//cdnjs.cloudflare.com/ajax/libs/gmaps.js/0.4.23/gmaps.min.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ body { text-align: center;
}
#gmapcood { margin: 10px auto; width: 90%; margin: 10px auto; height: 260px;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <h1>gmaps.js with refresh location button</h1>
<div id="gmapcood"></div> <script src="js/index.js"></script>
</body>
</html>

Gmaps.js with refresh location button - Script Codes CSS Codes

body { text-align: center;
}
#gmapcood { margin: 10px auto; width: 90%; margin: 10px auto; height: 260px;
}

Gmaps.js with refresh location button - Script Codes JS Codes

var onSuccess = function(position) { console.log(position); var map = new GMaps({ div: '#gmapcood', lat: position.coords.latitude, lng: position.coords.longitude, disableDefaultUI: true, zoom: 17, }); map.addMarker({ lat: position.coords.latitude, lng: position.coords.longitude, title: 'Your current location', }); map.addControl({ position: 'top_right', content: 'Refresh', style: { margin: '5px', padding: '4px 8px', border: 'solid 1px #717B87', background: '#fff' }, events: { click: function() { document.querySelector('#gmapcood').innerHTML = ""; initMap(); } } });
};
var onError = function(error) { alert(error.message + '\n(Code: ' + error.code + ')');
}
function initMap() { navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
initMap();
Gmaps.js with refresh location button - Script Codes
Gmaps.js with refresh location button - Script Codes
Home Page Home
Developer Gabriel
Username gab
Uploaded August 12, 2022
Rating 3
Size 2,293 Kb
Views 22,264
Do you need developer help for Gmaps.js with refresh location button?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Gabriel (gab) Script Codes
Create amazing blog posts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!