<script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3.1&sensor=true"></script>
<script type="text/javascript">
var r = confirm("We need your permission to get your location!");
if (r == true) {
function onPositionUpdate(position) {
document.getElementById("txtlati").value = position.coords.latitude;
document.getElementById("txtlongi").value = position.coords.longitude;
}
if (navigator.geolocation)
navigator.geolocation.getCurrentPosition(onPositionUpdate);
else
alert("navigator.geolocation is not available");
}
else {
x = "Sorry! You will be redirecting";
location.href("Default.aspx");
}
function initialize() {
var map = new google.maps.Map(document.getElementById("map_area"));
var myLatlng = new google.maps.LatLng(document.forms[0].txtlati.value, document.forms[0].txtlongi.value);
var myOptions = { zoom: 15, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP }
var map = new google.maps.Map(document.getElementById("map_area"), myOptions);
var marker = new google.maps.Marker({ position: myLatlng, draggable: true, flat: false, map: map, title: "Move pin to get latitude and longitude." });
google.maps.event.addListener(marker, "drag", function () {
var latlng = marker.getPosition();
document.forms[0].txtlati.value = latlng.lat();
document.forms[0].txtlongi.value = latlng.lng();
});
}
</script>
<div id="map_area" style="width: 700px; height: 500px">
</div>
и у меня есть текстовые поля в div.thats это.