OpenLayers3之根据范围设置地图缩放级别


OpenLayers3根据范围设置地图缩放级别

/*两种方式*/
//第一种
var r=map.getView().getResolutionForExtent(extent,map.getSize());
map.getView().setResolution(r);
map.getView().setCenter(ol.extent.getCenter(extent));
//第二种
map.getView().fit(extent,map.getSize());

转载自:https://blog.csdn.net/Console_DS/article/details/78589563

You may also like...