76百度地图:经纬度

很多场合都用到百度地图,这里是笔者把自己老家县政府的位置(经纬度)和老家住宅的位置(经纬度)在百度地图上标出来。
```html:run
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<title>固始县政府</title>
<style type="text/css">
body, html,#onlymap{width: 100%;height: 100%; margin:0;font-family:"微软雅黑";}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=vvNvGRSQV4QdtGZaoKDB04yW5mFBrFSX"></script>
</head>
<body>
<div id="onlymap"></div>
</body>
</html>
<script type="text/javascript">
//整体设置
var map = new BMap.Map("onlymap");
map.centerAndZoom(new BMap.Point(115.6608, 31.7575), 10);
map.enableScrollWheelZoom();
//笔者所在县=>固始县县政府位置
var countyGovernmentPoint = new BMap.Point(115.6608, 32.1749);
var countyGovernmentmarker = new BMap.Marker(countyGovernmentPoint);
map.addOverlay(countyGovernmentmarker);
var countyGovernmentPosition = countyGovernmentmarker.getPosition();
var countyGovernmentPositionLng=countyGovernmentPosition.lng;
var countyGovernmentPositionLat=countyGovernmentPosition.lat;
var countyGovernmentLabel = new BMap.Label("笔者所在县=>固始县县政府位置:<br/>东经"+countyGovernmentPositionLng+"度,北纬"+countyGovernmentPositionLat+"度",{offset:new BMap.Size(-105,37)});
countyGovernmentmarker.setLabel(countyGovernmentLabel);
var circle = new BMap.Circle(countyGovernmentPoint,500,{strokeColor:"red", strokeWeight:5, strokeOpacity:0.5});
map.addOverlay(circle);
//笔者老家住宅=>位置
var myFamilypoint = new BMap.Point(115.7097, 31.9053);
var myFamilymarker = new BMap.Marker(myFamilypoint);
map.addOverlay(myFamilymarker);
var myFamilyPosition = myFamilymarker.getPosition();
var myFamilyPositionLng=myFamilyPosition.lng;
var myFamilyPositionLat=myFamilyPosition.lat;
var myFamilyLabel = new BMap.Label("笔者老家住宅=>位置:<br/>东经"+myFamilyPositionLng+"度,北纬"+myFamilyPositionLat+"度",{offset:new BMap.Size(-75,28)});
myFamilymarker.setLabel(myFamilyLabel);
//左上角添加默认缩放平移控件
var topLeftNavigation = new BMap.NavigationControl();
map.addControl(topLeftNavigation);
</script>
```

猜你喜欢

转载自www.cnblogs.com/gushixianqiancheng/p/10967063.html