Update Location in Mapview Xcode

前端 未结 2 1212
我在风中等你
我在风中等你 2021-01-26 05:37

In my current project.

I need user\'s location at every 50 meter user move.

So Basically After open application every 50 meter change I

2条回答
  •  醉酒成梦
    2021-01-26 06:12

    1. You have to make object of CLLocationManager when application starts and set it's delegate

    Add the below code to get user's current location

    CLLocationManager *locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    [locationManager startUpdatingLocation];
    
    1. Now add the delegate of CLLocationManagaer that is didUpdateToLocation and add the following code in that.

      CLLocationDistance meters = [newLocation distanceFromLocation:oldLocation];

      if(meters==50)
      {
          // CALL YOU WEBSERVICE
      }
      

提交回复
热议问题