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

百度地图根据坐标点自动调整视图等级

程序员文章站 2022-03-04 12:33:15
...
//初始化地图
querymap = new BMap.Map("abc");
var point = new BMap.Point(90, 100);
var shopPoint= new BMap.Point(20, 100);
//提供点坐标数组
var pointArray =new Array(point,shopPoint)
//3.根据点坐标调整地图等级
setViewPort(pointArray,shopGoodMap)
function setViewPort(pointArray,map){
var viewPort = map.getViewport(pointArray)
map.centerAndZoom(viewPort.center, viewPort.zoom);
console.log(viewPort)
console.log(pointArray)
}

相关标签: baiduMap js