function bounds(positions = [], expand = 0) { let minLng = 180 let minLat = 90 let maxLng = -180 let maxLat = -90 positions.forEach(item => { minLng = Math.min(minLng, item.lng || item.x) minLat = Math.min(minLat, item.lat || item.y) maxLng = Math.max(maxLng, item.lng || item.x) maxLat = Math.max(maxLat, item.lat || item.y) }) if (expand > 0) { let diffLng = Math.abs(maxLng - maxLng) let diffLat = Math.abs(maxLat - minLat) minLng -= diffLng * expand minLat -= diffLat * expand maxLng += diffLng * expand maxLat += diffLat * expand } return { west: minLng, south: minLat, east: maxLng, north: maxLat } }
标签:minLat,maxLng,item,let,计算,maxLat,Cesium,十四,Math From: https://www.cnblogs.com/LJXXXX/p/17068120.html