openLayer 縮放到適合的窗口


//地圖對象 map.getMap() 獲取 openlayer.map 對象
var map;

var mapConfig = {
//初始縮放等級
initZoom: 8,
//最小縮放等級
minZoom: 8,
//最大縮放等級
maxZoom: 11,
//中心點
initCenterPt: [106.626800, 26.651400],
//顯示范圍 矩形坐標(貴州省)
viewExtent: [103.541675, 24.531748, 109.668466, 29.280013],
//使用圖層 2018-08-13 修改 最底層圖層為白色
baseLayerURLTemplate: "www.baidu.com",//地形圖地址
//控件顯示
controls: {
overviewMapControl: false,
copyrightControl: false
}
};


map = new SinoMap("mapContainer", mapConfig);//mapContainer 地圖放置位置 mapConfig 地圖的配置

map.getMap().getView().fit(ol.proj.transformExtent([Number(left_lng),Number(left_lat),Number(right_lng),Number(right_lat)], "EPSG:4326", "EPSG:3857"),{duration:300}
)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM