1

首先,我想从后端获取附近的商店。为此,我发送地图的中心纬度和经度以及地图的对角线距离。这样,我就得到了我当前视口下的附近商店。但是当我放大那个视口时,我并没有从服务器端获取商店。我正在使用 mapkit,并且在服务器端 mongo geonear 函数正在用于计算。

我很困惑如何解决这个问题。

下面是我的对角距离计算代码的简短片段

    let topLeftCorner = mapView.convert(.zero, toCoordinateFrom: mapView)
    let cllocationTopLeftCorner = CLLocation(latitude: topLeftCorner.latitude, longitude: topLeftCorner.longitude)
    //Center viewPort lat, long  of map
    let centerPoint = mapView.centerCoordinate
    let cllocationOfCenter = CLLocation(latitude: centerPoint.latitude, longitude: centerPoint.longitude)

    //calculating air distance from two lat long
    let distanceFromCenter = cllocationTopLeftCorner.distance(from: cllocationOfCenter)
4

0 回答 0