Use
HTML5 Geolocation[
^] for getting the user's location -
<script>
var lat = 0; lon = 0;
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
lat = position.coords.latitude;
lon = position.coords.longitude;
}
</script>
And those
lat
and
lon
in google's map -
function initialize() {
var mapProp = {
center:new google.maps.LatLng(lat, lon),
zoom:5,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
}
google.maps.event.addDomListener(window, 'load', initialize);
Refer this -
Create a Basic Google Map[
^]
-KR