code
HTML
<h3>My Google Maps Demo</h3>
<div id="map"></div>
<!-- Replace the value of the key parameter with your own API key. -->
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCZj6jlvGwL0uIzag">
</script>
JS
function initMap() {
}
let options = {
};
function success( {coords}) {
console.log = ` ${coords.latitude},${coords.longitude}`;
let myPos = {lat: coords.latitude, lng: coords.longitude};
let map = new google.maps.Map(document.getElementById('map'), {
zoom: 15,
center: myPos
});
var marker = new google.maps.Marker({
position: myPos,
map: map
});
};
function error(err) {
console.warn(`ERROR(${err.code}): ${err.message}`);
};
navigator.geolocation.getCurrentPosition(success, error, options);