I have the following code below:
<!DOCTYPE html>
<head>
<title>Geolocation Service</title>
<script src="http://maps.googleapis.com/maps/api/js"></script>
<script>
function initialize() {
var lat = ???;
var lng = ???;
var map = {
center:new google.maps.LatLng(lat,lng),
zoom:5,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("mapcontainer"), map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="mapcontainer">
<!--Map goes here-->
</div>
</body>
<style>
*
{
margin: 0;
}
#mapcontainer
{
width: 100vw;
height: 100vh;
}
</style>
</html>
In my variable lat
and lng
, I set them to ???
because I dont know how to get the my current position. I just started learning Google Geolocation API. Thanks!