百度地图API自动根据点的经纬度来控制地图显示范围

根据点的经纬度控制地图显示范围:

//创建点
var point1 = new BMap.Point(lng1,lat1);
var point2 = new BMap.Point(lng2,lat2);

var points = [point1, point2];
var view = map.getViewport(eval(points));
var mapZoom = view.zoom; 
var centerPoint = view.center; 
map.centerAndZoom(centerPoint,mapZoom);
posted @ 2020-01-02 13:50  二次元的程序猿  阅读(1210)  评论(0编辑  收藏  举报