<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="WebApplication4.index" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta name="baidu-site-verification" content="zyu2elKF1h">
<meta name="robots" content="noodp">
<title>定位</title>
<link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
<%--先申請key值--%>
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=9ac9840832477736878e71d403cbe6d55"></script>
<script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
<style type="text/css">
/*刪除高德地圖的logo*/
.amap-logo {
right: 0 !important;
left: auto !important;
display: none;
}
.amap-copyright {
right: 70px !important;
left: auto !important;
}
</style>
</head>
<body>
<div id='container'></div>
<div id="tip"></div>
<script type="text/javascript">
var map, geolocation;
//加載地圖,調用瀏覽器定位服務
map = new AMap.Map('container', {
resizeEnable: true
});
map.plugin('AMap.Geolocation', function () {
geolocation = new AMap.Geolocation({
enableHighAccuracy: true,//是否使用高精度定位,默認:true
timeout: 10000, //超過10秒后停止定位,默認:無窮大
buttonOffset: new AMap.Pixel(10, 20),//定位按鈕與設置的停靠位置的偏移量,默認:Pixel(10, 20)
zoomToAccuracy: false, //定位區域
buttonPosition: 'RB'
});
map.addControl(geolocation);
geolocation.getCurrentPosition();
AMap.event.addListener(geolocation, 'complete', onComplete);//返回定位信息
AMap.event.addListener(geolocation, 'error', onError); //返回定位出錯信息
});
//解析定位結果
function onComplete(data) {
var str = ['定位成功'];
str.push('經度:' + data.position.getLng());
str.push('緯度:' + data.position.getLat());
str.push('精度:' + data.accuracy + ' 米');
str.push('是否經過偏移:' + (data.isConverted ? '是' : '否'));
document.getElementById('tip').innerHTML = str.join('<br>');
}
//解析定位錯誤信息
function onError(data) {
document.getElementById('tip').innerHTML = '定位失敗';
}
</script>
</body>
</html>

相關資料的查看地址:
各種demo的在線編輯查看地址http://lbs.amap.com/api/javascript-api/example/location/browser-location/?demo
高德自己做的: 打開即有相應的定位信息http://ditu.amap.com/
需要自己申請key值,應用等,登陸賬號(同百度地圖)
