mardi 20 octobre 2015

How can i save my travelled route map into sqlite database in ios

I am new for iOS present working on google maps.

I would like to save my travelled route map (with polyline) into my database like Runtastic Application.

Present getting polyline when i am moving.

this is the code till i am using.

 - (void)startLocationUpdates
   {

     if (self.locationManager == nil) {
        self.locationManager = [[CLLocationManager alloc] init];
    }

   self.locationManager.delegate = self;
   self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
   self.locationManager.activityType = CLActivityTypeFitness; 
   self.locationManager.distanceFilter = 8; // meters
   [self.locationManager startUpdatingLocation];

  }

  - (void)locationManager:(CLLocationManager *)manager
    didUpdateLocations:(NSArray *)locations
  {

   for (CLLocation *newLocation in locations) {

    if (self.locations.count > 0) {

        self.distance += [newLocation distanceFromLocation:self.locations.lastObject];            
        CLLocationCoordinate2D coords[2];
        coords[0] = ((CLLocation *)self.locations.lastObject).coordinate;
        coords[1] = newLocation.coordinate;            
        MKCoordinateRegion region =
        MKCoordinateRegionMakeWithDistance(newLocation.coordinate, 300, 300);
        [self.mapView setRegion:region animated:YES];            
        [self.mapView addOverlay:[MKPolyline polylineWithCoordinates:coords count:2]];

    }

    [self.locations addObject:newLocation];

     }
  }
 - (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id    < MKOverlay >)overlay
  {
  if ([overlay isKindOfClass:[MKPolyline class]]) {
    MKPolyline *polyLine = (MKPolyline *)overlay;
    MKPolylineRenderer *aRenderer = [[MKPolylineRenderer alloc] initWithPolyline:polyLine];
    aRenderer.strokeColor = [UIColor blueColor];
    aRenderer.lineWidth = 3;
    return aRenderer;
}
return nil;

}

Now i want save that map details into database and retrieve it again and show it as a MapView.

Thank you in advance.

Aucun commentaire:

Enregistrer un commentaire