here is my java script code
function onSuccess(position) {
var element = document.getElementById('map');
var lat=position.coords.latitude;
var lang=position.coords.longitude;
var myLatlng = new google.maps.LatLng(lat,lang);
var mapOptions = {zoom: 10,center: myLatlng};
var map = new google.maps.Map(document.getElementById('map'), mapOptions);
var marker = new google.maps.Marker({position: myLatlng,map: map});
map.setCenter(myLatlng);
}
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
var watchID = navigator.geolocation.watchPosition(onSuccess, onError, { timeout: 3000 });
google.maps.event.addDomListener(window, 'load', onSuccess);
1 Answer(s)