navigator.geolocation.getCurrentPosition(successCallback);
function successCallback(position){
var lat = position.coords.latitude;
var long = position.coords.longitude;
}
var map;
function initMap() {
map = new google.maps.Map(document.getElementById("map"), {
center: {lat: lat, lng: long},
zoom: 8
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=xxx&callback=initMap"
async defer></script>
Update code ~
so how to transfer lat and long to initMap?