У меня есть следующая функция для извлечения текущей позиции пользователя (если разрешено).
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
<script type="text/javascript">
(function () {
google.load("maps", "2");
google.setOnLoadCallback(function () {
// Create map
var map = new google.maps.Map2(document.getElementById("map_canvas")),
markOutLocation = function (lat, long) {
var latLong = new google.maps.LatLng(lat, long),
marker = new google.maps.Marker(latLong);
map.setCenter(latLong, 13);
map.addOverlay(marker);
marker.openInfoWindow(markerText);
google.maps.Event.addListener(marker, "click", function () {
marker.openInfoWindow(markerText);
});
};
map.setUIToDefault();
// Check for geolocation support
if (navigator.geolocation) {
// Get current position
navigator.geolocation.getCurrentPosition(function (position) {
// Success!
markOutLocation(position.coords.latitude, position.coords.longitude);
},
function () {
// Gelocation fallback: Defaults to Stockholm, Sweden
markOutLocation(59.3325215, 18.0643818);
}
);
}
else {
// No geolocation fallback: Defaults to Eeaster Island, Chile
markOutLocation(-27.121192, -109.366424);
}
});
})();
</script>
Если я поставлю alert(lat + ', ' + long);
над map.setCenter(latLong, 13);
, я получу 59.378217, 13.504219 в окне предупреждения,Как мне получить эту информацию в DIV-теге внутри BODY-тега?
Заранее спасибо.