HTML5一步一步走——地理应用(六)
程序员文章站
2023-02-28 15:24:43
地理信息应用获取自己的位置:
[javascript]
function $(id) { return document.getelementbyid(id); }
wind...
地理信息应用获取自己的位置:
[javascript]
function $(id) { return document.getelementbyid(id); }
window.onload = function() {
if (navigator.geolocation) {
navigator.geolocation.getcurrentposition(
function(pos) {
$("lat").innerhtml = pos.coords.latitude;//纬度
$("lon").innerhtml = pos.coords.longitude;//经度
$("alt").innerhtml = pos.coords.altitude;//高度
$("accuracy").innerhtml = pos.coords.accuracy;
$("altitudeaccuracy").innerhtml = pos.coords.altitudeaccuracy;
$("heading").innerhtml = pos.coords.heading;
$("speed").innerhtml = pos.coords.speed;
$("timestamp").innerhtml = pos.timestamp;
// $("status").innerhtml = json.stringify(pos);
},
function() {}, www.2cto.com
{enablehighaccuracy:true, maximumage:600000}
);
} else {
$("status").innerhtml =
'no geolocation support for your browser';
}
}
作者:shiyuan17
[javascript]
function $(id) { return document.getelementbyid(id); }
window.onload = function() {
if (navigator.geolocation) {
navigator.geolocation.getcurrentposition(
function(pos) {
$("lat").innerhtml = pos.coords.latitude;//纬度
$("lon").innerhtml = pos.coords.longitude;//经度
$("alt").innerhtml = pos.coords.altitude;//高度
$("accuracy").innerhtml = pos.coords.accuracy;
$("altitudeaccuracy").innerhtml = pos.coords.altitudeaccuracy;
$("heading").innerhtml = pos.coords.heading;
$("speed").innerhtml = pos.coords.speed;
$("timestamp").innerhtml = pos.timestamp;
// $("status").innerhtml = json.stringify(pos);
},
function() {}, www.2cto.com
{enablehighaccuracy:true, maximumage:600000}
);
} else {
$("status").innerhtml =
'no geolocation support for your browser';
}
}
作者:shiyuan17