欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

百度地图api js 设置多个坐标处于地图视图中心

程序员文章站 2022-03-04 12:29:39
...
var overlays = [
	new BMap.Point(106.602849,29.562462),new BMap.Point(106.635619,29.595882),
	new BMap.Point(106.65143,29.571383),new BMap.Point(106.65143,29.571383),
	new BMap.Point(106.5948,29.52815),new BMap.Point(106.602849,29.562462)
];
				
	var map = new BMap.Map("map",{enableMapClick:false});
				
	var center = new BMap.Point(106.554413,29.557184);
			    
	map.centerAndZoom(center,12); //设置地图中心位置,并设置地图大小级别
	//map.enableScrollWheelZoom();//启用地图滚轮放大缩小  
	map.addControl(new BMap.NavigationControl()); //向地图中添加缩放控件 
	map.addControl(new BMap.ScaleControl());  //向地图中添加比例尺控件
				
  	map.clearOverlays();
  	var polyline_juxing = new BMap.Polyline(overlays, {
		strokeColor : "blue",
		strokeWeight : 3,
		strokeOpacity : 1
	});
	map.addOverlay(polyline_juxing);//添加矩形   
      			
	map.setViewport(overlays);
map.setViewport(overlays);  //可以设置多个坐标点处于地图中,自动设置地图级别