<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
>
<
meta
http-equiv
="Content-Type"
content
="text/html; charset=utf-8"
/>
<!--
引用百度地圖API
-->
<
script
type
="text/javascript"
src
="http://api.map.baidu.com/api?v=1.1&services=true"
></
script
>
</
head
>
<
body
>
<!--
百度地圖容器
-->
<
div
style
="width:697px;height:550px;border:#ccc solid 1px;"
id
="dituContent"
></
div
>
</
body
>
<
script
type
="text/javascript"
>
var
map
=
new
BMap.Map(
"
dituContent
"
);
var
point
=
new
BMap.Point(
116.331398
,
39.897445
);
map.centerAndZoom(point,
12
);
map.enableScrollWheelZoom();
var
geolocation
=
new
BMap.Geolocation();
geolocation.getCurrentPosition(
function
(r){
if
(
this
.getStatus()
==
BMAP_STATUS_SUCCESS){
var
mk
=
new
BMap.Marker(r.point);
map.addOverlay(mk);
map.panTo(r.point);
alert(
'
您的位置:
'
+
r.point.lng
+
'
,
'
+
r.point.lat);
}
else
{
alert(
'
failed
'
+
this
.getStatus());
}
})
</
script
>
</
html
>