You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
2.3 KiB
61 lines
2.3 KiB
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
|
pageEncoding="UTF-8"%>
|
|
<!DOCTYPE>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
|
<style type="text/css">
|
|
body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
|
|
</style>
|
|
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=GN7LulhISwEhqUXTNVDkt5MGc12f0mIF"></script>
|
|
<title>浏览器定位(百度地图)</title>
|
|
</head>
|
|
<body>
|
|
<body>
|
|
<div id="allmap"></div>
|
|
</body>
|
|
</html>
|
|
<script type="text/javascript">
|
|
// 百度地图API功能
|
|
var map = new BMap.Map("allmap");
|
|
var point = new BMap.Point(118.825966,32.044895);
|
|
map.centerAndZoom(point,16);
|
|
|
|
/* map.setMapStyle({style:'light'}); */
|
|
|
|
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());
|
|
}
|
|
},{enableHighAccuracy: true})
|
|
//关于状态码
|
|
//BMAP_STATUS_SUCCESS 检索成功。对应数值“0”。
|
|
//BMAP_STATUS_CITY_LIST 城市列表。对应数值“1”。
|
|
//BMAP_STATUS_UNKNOWN_LOCATION 位置结果未知。对应数值“2”。
|
|
//BMAP_STATUS_UNKNOWN_ROUTE 导航结果未知。对应数值“3”。
|
|
//BMAP_STATUS_INVALID_KEY 非法密钥。对应数值“4”。
|
|
//BMAP_STATUS_INVALID_REQUEST 非法请求。对应数值“5”。
|
|
//BMAP_STATUS_PERMISSION_DENIED 没有权限。对应数值“6”。(自 1.1 新增)
|
|
//BMAP_STATUS_SERVICE_UNAVAILABLE 服务不可用。对应数值“7”。(自 1.1 新增)
|
|
//BMAP_STATUS_TIMEOUT 超时。对应数值“8”。(自 1.1 新增)
|
|
|
|
|
|
map.centerAndZoom(new BMap.Point(118.825966,32.044895), 16); // 初始化地图,设置中心点坐标和地图级别
|
|
//添加地图类型控件
|
|
map.addControl(new BMap.MapTypeControl({
|
|
mapTypes:[
|
|
BMAP_NORMAL_MAP,
|
|
BMAP_HYBRID_MAP
|
|
]}));
|
|
map.setCurrentCity("南京"); // 设置地图显示的城市 此项是必须设置的
|
|
map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放
|
|
</script>
|