1

First, I want to get the nearby shop from the backend. For that, I am sending Center latitude and longitude of the map and the diagonal distance of map. By that, I am getting the nearby shop which is under my current viewport. But when I zoom in on that viewport then I am not getting the shop from server side. I am using mapkit and in serverside mongo geonear function is getting used for calculation.

I am very confused how to solve this issue.

Below is the short snippet of my code for diagonal distance calculation

    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)
Arindam
  • 61
  • 4

0 Answers0