Description:
In operation, the map, there is a function, click a point, click on the view point to the location of, and amplification.
solution:
1, there can be openlayers have ol.View can be controlled, but when you change, will be set when the map is initialized maxZoom, minZoom etc. overwritten, it is necessary before setting a new view, once again set the value at initialization, avoid duplication of coverage.
/ * * * Location Center and zoom map @description event * @param {Map} _map map objects * @param {Feature} _feature to locate elements * @param {Number} _zoomLevel zoom level * / the this .zoomAndCenter = function (_MAP , _feature, _zoomLevel) { var the my_view = new new ol.View ({ Center:. ol.extent.getCenter (_feature.getGeometry () getExtent ()), // format: [X, Y] Zoom: _zoomLevel, minZoom,: _MAP . .encmap.getView () getMinZoom (), the maxZoom:. _map.encmap.getView () getMaxZoom () }); _map.encmap.setView (the my_view); };
2, set the center and zoom alone, it is recommended!
let view = _map.encmap.getView();
view.setZoom(_zoomLevel);
view.setCenter(ol.extent.getCenter(_feature.getGeometry().getExtent()));