百度地图 web定位

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<title>测试定位</title>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4"></script>
<style type="text/css">
#mapContainer{width:100%;height:400px;border:1px solid gray;}</style>
</head>
<body>
<div id="mapContainer"></div>
<script type="text/javascript" >
var origin = "0,0";
var origin_region = "";
var point = new BMap.Point(118.185789, 24.489321);
var map = new BMap.Map("mapContainer");
map.enableScrollWheelZoom();
map.centerAndZoom(point, 15);
var marker = new BMap.Marker(point);
map.addOverlay(marker);

var gectrl=new BMap.GeolocationControl( {
anchor:BMAP_ANCHOR_TOP_LEFT,
enableAutoLocation: true });
map.addControl(gectrl); //添加定位控件


var myCity = new BMap.LocalCity();
myCity.get(function(result){ origin_region = result.name; });

var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function (r) {
if (this.getStatus() == BMAP_STATUS_SUCCESS ) {
origin = r.point.lng + "," + r.point.lat;
alert(origin);
}
})
</script>
</body></html>

百度地图 web定位,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。