Here I have created smaple that full-fill your requirement.
HTML
<div>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
window.onload = function () {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
document.getElementById("<%=txtCoordinate.ClientID %>").value = latitude + ',' + longitude;
var mapOptions = {
center: new google.maps.LatLng(latitude, longitude),
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var infoWindow = new google.maps.InfoWindow();
var latlngbounds = new google.maps.LatLngBounds();
var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
google.maps.event.addListener(map, 'click', function (e) {
var latlng = new google.maps.LatLng(e.latLng.lat(), e.latLng.lng());
var geocoder = geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'latLng': latlng }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
//alert("Location: " + results[1].formatted_address + "\r\nLatitude: " + e.latLng.lat() + "\r\nLongitude: " + e.latLng.lng());
document.getElementById("<%=txtCoordinate.ClientID %>").value = e.latLng.lat() + ',' + e.latLng.lng();
}
}
});
});
});
} else {
alert("Geolocation API is not supported in your browser.");
}
}
</script>
<div id="dvMap" style="width: 400px; height: 400px">
</div>
<br />
<br />
Coordinate :<asp:TextBox ID="txtCoordinate" runat="server" /><br />
</div>
Screenshot
