<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<link rel="stylesheet" type="text/css" href="css/scxnTabDiv.css"/>
<link rel="stylesheet" type="text/css" href="css/baidu.css" />
<title>
地图
</title>
</head>
<body>
<!--input type="BUTTON" name="FullScreen" value="打印" onclick="printMap()"></input-->
<!--startprint-->
<div id="allmap" onselectstart="return false;" oncontextmenu="closePolyLine();enableDragging();" style="height: 100%;position:relative;">
</div>
<!--endprint-->
<div id="ss" />
<div id="map_hidetools" style="height:100%;top:50%;" onclick="showToolPanel()">
>
</div>
</div>
<div id="map_tools">
<input id="x">
经度
</button>
<input id="y">
纬度
</button>
<button onclick="panTo(document.getElementById('x').value,document.getElementById('y').value)">
定位
</button>
<div id="map_points">
<div id="point_hidebutton">
</div>
<div id="point_checkbox">
</div>
<div id="point_selection">
</div>
<input id="bookMarkName" style="width:50px"></input>
<input type="BUTTON" name="FullScreen" value="添加书签" onclick="addBookMark(document.getElementById('bookMarkName').value)"></input>
<br/>
<select id="bookmarkselect">
</select>
<button onclick="gotoBookMark()">
定位书签
</button>
</div>
<div id="loading_div" style="position:absolute;width:100%;height:100%;top:0;background-color:white;z-index:999;text-align:center;padding-top:300px;">
加载中...
</div>
<div id="info_div" style="width='280px';height='200px;'">
</div>
<div id="img_div" style="display: none; position: absolute; width: 100px; height: 100px;">
</div>
<button onclick="openDis()">
测距
</button>
<input type="BUTTON" name="FullScreen" value="全屏显示" onclick="window.open(document.location, 'big', 'fullscreen=yes')"></input>
<input type="BUTTON" name="FullScreen" value="全图" onclick="initCenterAndZoom()"></input>
<input type="BUTTON" name="FullScreen" value="拉框放大" onclick="openDrag()"></input>
<input type="BUTTON" name="FullScreen" value="平移" onclick="panning()"></input>
<input type="BUTTON" name="FullScreen" value="切片" onclick="map.setMapType(BMAP_NORMAL_MAP)"></input>
<input type="BUTTON" name="FullScreen" value="影像" onclick="map.setMapType(BMAP_HYBRID_MAP)"></input>
<input type="BUTTON" name="FullScreen" value="简/详" onclick="changeLabelContent()"></input>
<input type="BUTTON" name="FullScreen" value="画线" onclick="openPolyLine()"></input>
<input type="BUTTON" name="FullScreen" value="清除画线" onclick="clearPolyLine()"></input>
<input type="BUTTON" name="FullScreen" value="固定" onclick="disableDragging()"></input>
<input type="BUTTON" name="FullScreen" value="取消固定" onclick="enableDragging()"></input>
<input type="BUTTON" name="FullScreen" value="更新" onclick="testUpdate()"></input>
<input type="BUTTON" name="FullScreen" value="打印" onclick="printMap()"></input>
</body>
</html>
<script type="text/javascript" src="js/BaiduApi_2.0.js">
</script>
<script type="text/javascript" src="js/AreaRestriction_min.js">
</script>
<script type="text/javascript" src="js/TextIconOverlay_min.js">
</script>
<script type="text/javascript" src="js/scxnLabel.js">
</script>
<script type="text/javascript" src="js/config.js">
</script>
<script type="text/javascript" src="js/DistanceTool_min.js">
</script>
<script type="text/javascript" src="js/data_Map.js">
</script>
<script type="text/javascript" src="js/RectangleZoom_min.js">
</script>
<script type="text/javascript" src="js/ScxnTools.js">
</script>
<script type="text/javascript" src="js/scxnTabDiv.js">
</script>
<script type="text/javascript">
var baiduX = new Array(0,0,1,3,6,12,24,49,98,197,395,790,1581,3163,6327,12654,25308,50617);
var baiduY = new Array(0,0,0,1,2,4,9,18,36,73,147,294,589,1178,2356,4712,9425,18851);
var googleX = new Array(0,1,3,7,13,26,52,106,212,425,851,1702,3405,6811,13623,27246,54492,107917);
var googleY = new Array(0,0,1,2,5,12,23,47,95,190,380,761,1522,3045,6091,12183,24366,47261);
function toGoogleX(x,z){
var b = baiduX[z-1];//395
var g = googleX[z-1];//11:843,12:1685
var gx = g + (x-b);// --- 1587+
//谷歌瓦片行编号=[谷歌参照瓦片行编号+(百度行编号 – 百度参照瓦片行编号)]
return gx;
}
function toGoogleY(y,z){
var b = baiduY[z-1];//147
var g = googleY[z-1];//10:
var gy = g - (y-b);//
//谷歌瓦片列编号=[谷歌参照瓦片列编号- (百度列编号 – 百度参照瓦片列编号)] //向上,列为递减
//alert(y);
return gy;
}
//var addMarkerFlag = false;
//var mouseCursor;
var dataMap = new HashMap();
var labelMap = new HashMap();
var bkmkMap = new HashMap(); //bookMark书签map
var lineArray = new Array(); //线集合
var currLine = ""; //当前画线
var polyflag = false; //画线开关
var brTag = document.createElement("br");
var currShowLabel = null;
var isPanelShow = !isPanelShow();
var isComplexShow = isComplexShow();
var defaultCursor = null;
var isFixedMap = false;
//初始化地图
var map = new BMap.Map('allmap', {
mapType: getDefaultMapType()
});
var overlayTileLayer = new BMap.TileLayer({isTransparentPng: true});
overlayTileLayer.getTilesUrl = function(tileCoord, zoom) {
var x = tileCoord.x;
var y = tileCoord.y;
//var gx = toGoogleX(x,zoom);//建议注释
//var gy = toGoogleY(y,zoom);//建议注释
//var url = 'overlay/' + (zoom-1) + "/" + gx + "/" + gy + ".png"; //根据当前坐标,选取合适的瓦片图,不建议此方法,会导致拖动的时候卡顿,建议直接使用百度瓦片
var url = 'overlay/' + (zoom-1) + "/" + x + "/" + y + ".png"; //直接使用本地瓦片
//document.getElementById("info_div").innerHTML+=url+"<br/>";
return url;
}
map.addTileLayer(overlayTileLayer);
//添加缩放控件
if(isAddNavigation()){
map.addControl(new BMap.NavigationControl({
anchor: BMAP_ANCHOR_TOP_RIGHT,
type: BMAP_NAVIGATION_CONTROL_LARGE
}));
}
//添加点击事件
map.addEventListener('click', function(e) {
//画线
//document.getElementById("info_div").innerHTML += "</br>"+e.point.lng+","+e.point.lat;
if(polyflag){
if(currLine!=""){
currLine+= ";";
map.removeOverlay(lineArray.pop());
}
currLine+=e.point.lng+","+e.point.lat;
lineArray.push(addPolyline(currLine,getPolyLineColor(),0.8,getPolyLineWidth()));
}
});
//开启画线
function openPolyLine(){
polyflag = true;
currLine = "";
map.setDefaultCursor("default");
}
//关闭画线
function closePolyLine(){
polyflag = false;
map.setDefaultCursor(defaultCursor);
}
//清除画线
function clearPolyLine(){
while(lineArray.length>0){
var l = lineArray.shift();
map.removeOverlay(l);
}
closePolyLine();
}
initCenterAndZoom(); //初始化中心点
if(isEnableScrollWheelZoom()){
map.enableScrollWheelZoom(); //启用滚动缩放
}
if(!isEnableDoubleClickZoom()){
map.disableDoubleClickZoom(); //禁用双击放大
}
map.enableContinuousZoom();
//map.addControl(new BMap.ScaleControl());//
if(isCreateScale()){
map.addControl(new BMap.ScaleControl({anchor: BMAP_ANCHOR_BOTTOM_LEFT})); //比例尺 左下
}
var myDis = new BMapLib.DistanceTool(map); //测距控�
评论0