Отправьте запрос POST и поместите полученные данные в MKMapView - PullRequest
0 голосов
/ 24 марта 2020

У меня работает сервер node.js с массивом географических данных в URL. Я хотел бы отправить ему запрос POST из iOS приложения и заполнить карту моего приложения точками. данные структурированы следующим образом:

{
   'lat': 13.37,
   'long': 42.00,
   'name': 'epic geographic datapoint'
}

Я бы хотел сказать, что что-то пробовал, но здесь я полностью потерян. Я новичок в iOS разработке, но вот мой код:

class ViewController: UIViewController, CLLocationManagerDelegate {

    let manager = CLLocationManager()

    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
        let location = locations[0]
        let userCurrentLocation:CLLocationCoordinate2D = CLLocationCoordinate2DMake(location.coordinate.latitude, location.coordinate.longitude)
        let region = MKCoordinateRegion.init(center: userCurrentLocation, latitudinalMeters: 100, longitudinalMeters: 100);
        map.setRegion(region, animated: true) 
    }

    //MAP
    @IBOutlet var map: MKMapView!
    override func viewDidLoad() {
        super.viewDidLoad()
        manager.delegate = self
        manager.desiredAccuracy = kCLLocationAccuracyBest
        manager.requestWhenInUseAuthorization();
        manager.startUpdatingLocation();
        // Do any additional setup after loading the view.
    }

    //POST an endpoint and populate the MKMapView
}

Спасибо.

...