HTML5一步一步走——地理应用(六)
程序员文章站
2022-05-20 18:51:56
地理信息应用获取自己的位置:
[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
上一篇: php设计模式及耦合性和多形性
下一篇: PHP:保留小数点后一位,并且不四舍五入