HTML5 geolocation API获得用户当前城市名
来源:互联网 发布:php新浪面试题及答案 编辑:程序博客网 时间:2024/05/11 18:35
<!DOCTYPE html>
<html >
<head>
<title>HTML5 Demo: geolocation</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAZNVcM3B5rUU5SJeXURUaBxTBfUk9TZrBRaIteybtnU2KziHEpRTn4b5CncoKZUG6YvDa1nKeST_Y5A"
type="text/javascript"></script>
</head>
<body >
<script>
var geocoder = null;
function addAddressToMap(response) {
if (!response || response.Status.code != 200) {
alert("对不起,不能解析这个地址");
} else {
var add = "";
for (var i = 0; i < response.Placemark.length; i++) {
add += response.Placemark[i].address + " | ";
}
alert("您查找的位置是 : " + add.substr(5,3));
}
}
function showLocation(address) {
if (GBrowserIsCompatible()) {
geocoder = new GClientGeocoder();
geocoder.getLocations(address, addAddressToMap);
}
}
function success(position) {
alert(position.coords.latitude);
alert(position.coords.longitude);
showLocation(position.coords.latitude + "," + position.coords.longitude);
return position.coords.latitude + "," + position.coords.longitude;
}
function error(msg) {
// var s = document.querySelector('#status');
// s.innerHTML = typeof msg == 'string' ? msg : "failed";
// s.className = 'fail';
// console.log(arguments);
}
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, error);
} else {
error('not supported');
}
</script>
</body>
<html >
<head>
<title>HTML5 Demo: geolocation</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAZNVcM3B5rUU5SJeXURUaBxTBfUk9TZrBRaIteybtnU2KziHEpRTn4b5CncoKZUG6YvDa1nKeST_Y5A"
type="text/javascript"></script>
</head>
<body >
<script>
var geocoder = null;
function addAddressToMap(response) {
if (!response || response.Status.code != 200) {
alert("对不起,不能解析这个地址");
} else {
var add = "";
for (var i = 0; i < response.Placemark.length; i++) {
add += response.Placemark[i].address + " | ";
}
alert("您查找的位置是 : " + add.substr(5,3));
}
}
function showLocation(address) {
if (GBrowserIsCompatible()) {
geocoder = new GClientGeocoder();
geocoder.getLocations(address, addAddressToMap);
}
}
function success(position) {
alert(position.coords.latitude);
alert(position.coords.longitude);
showLocation(position.coords.latitude + "," + position.coords.longitude);
return position.coords.latitude + "," + position.coords.longitude;
}
function error(msg) {
// var s = document.querySelector('#status');
// s.innerHTML = typeof msg == 'string' ? msg : "failed";
// s.className = 'fail';
// console.log(arguments);
}
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, error);
} else {
error('not supported');
}
</script>
</body>
</html>
http://zhan.renren.com/lovecodes?gid=3602888498024546812&from=post&checked=true
或者画出地理位置图: http://www.2cto.com/kf/201205/130760.html
0 0
- HTML5 geolocation API获得用户当前城市名
- html5 geolocation / 百度地图api Geolocation 定位当前城市信息
- html5 geolocation/ 百度地图api Geolocation 定位当前城市信息
- html5 geolocation / 百度地图api Geolocation 定位当前城市信息
- html5 geolocation / 百度地图api Geolocation 定位当前城市信息&window.navigator.geolocation.getCurrentPosition,在IO
- Google Geolocation Module API获得客户端当前所在城市名
- HTML5的Geolocation API
- HTML5之Geolocation API
- HTML5 Geolocation API
- 使用HTML5的geolocation API
- HTML5地理位置定位 Geolocation API
- HTML5 geolocation API的用法
- HTML5 的定位api geolocation
- 利用html5新增geolocation对象加百度地图API获取用户详细地址
- HTML5 之Geolocation API (地理位置应用程序接口)
- HTML5中的地理定位API(Geolocation)
- HTML5 Geolocation用来定位用户的位置。
- 获取当前城市的城市名
- 手机的重要性手机病毒如何防,六招远离手机病毒技巧分享
- ListView特殊设置
- nor flash和nand flash的区别
- 开始执行不调试和直接点击exe的区别?
- HDU 1850 Being a Good Boy in Spring Festival 尼姆博弈(找可选择的数量)
- HTML5 geolocation API获得用户当前城市名
- java学习笔记13——类成员
- How to Interpret the "SQL ordered by Physical Reads (UnOptimized)" Section in AWR (文档 ID 1466035.1)
- maven可執行jar包
- ARM学习笔记--LPC1788引脚分析
- 《和时间做朋友》读后感
- HDU2049-递推式
- 从零开始学习cocoStudio(6)--场景
- parallels 如何备份虚拟机