1. 以播放圖標爲中心,往外擴大五公里範圍,如下圖所示:
2. 代碼如下
//一開始執行的方法
ngOnInit(){
//中心點
var positionCenter = [維度, 經度]
//調用計算方法
this.getAround(centerY, centerX, 5000);
定位到中心點位,13是地圖的級別
map.setView(positionCenter, 13);
}
//計算方法
getAround(latitude, longitude, raidus) {
const degree = (24901 * 1609) / 360.0; // 獲取每度
const mpdLng = degree * Math.cos(latitude * (3.141592653 / 180));
const dpmLng = 1 / mpdLng;
const radiusLng = dpmLng * raidus;
//獲取最小經度
const minLat = parseFloat(longitude) - radiusLng;
// 獲取最大經度
const maxLat = longitude + radiusLng;
const dpmLat = 1 / degree;
const radiusLat = dpmLat * raidus;
// 獲取最小緯度
const minLng = parseFloat(latitude) - radiusLat;
// 獲取最大緯度
con