如何将旅行路线图信息保存到ios中的sqlite数据库中

如何将旅行路线图信息保存到ios中的sqlite数据库中,ios,objective-c,sqlite,mkmapview,mkpolyline,Ios,Objective C,Sqlite,Mkmapview,Mkpolyline,我是iOS新手,在谷歌地图上工作 我想像Runtastic应用程序一样将我的旅行路线图(带多段线)保存到我的数据库中 当前正在移动时获取多段线 这是我使用之前的代码 - (void)startLocationUpdates { if (self.locationManager == nil) { self.locationManager = [[CLLocationManager alloc] init]; } self.locationMan

我是iOS新手,在谷歌地图上工作

我想像Runtastic应用程序一样将我的旅行路线图(带多段线)保存到我的数据库中

当前正在移动时获取多段线

这是我使用之前的代码

 - (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;
-(无效)StartLocationUpdate
{
if(self.locationManager==nil){
self.locationManager=[[CLLocationManager alloc]init];
}
self.locationManager.delegate=self;
self.locationManager.desiredAccuracy=KCallocationAccuracyBest;
self.locationManager.activityType=CLActivityTypeFitness;
self.locationManager.distanceFilter=8;//米
[self.locationManager startUpdatingLocation];
}
-(无效)locationManager:(CLLocationManager*)经理
didUpdateLocations:(NSArray*)位置
{
用于(CLLocation*位置中的新位置){
如果(self.locations.count>0){
self.distance+=[newLocation distance fromLocation:self.locations.lastObject];
CLLocationCoordinate2D坐标[2];
坐标[0]=((CLLocation*)self.locations.lastObject).coordination;
coords[1]=newLocation.coordination;
MK协调区域=
MKCoordinateRegionMakeWithDistance(newLocation.coordinate,300300);
[self.mapView setRegion:区域动画:是];
[self.mapView addOverlay:[MKPolyline polyline polylineWithCoordinates:coords count:2];
}
[self.locations addObject:newLocation];
}
}
-(MKOverlayRenderer*)地图视图:(MKMapView*)地图视图渲染器ForOverlay:(id)overlay
{
if([overlay iskindof类:[MKPolyline类]]){
MKPolyline*polyLine=(MKPolyline*)覆盖;
MKPolylineRenderer*arender=[[MKPolylineRenderer alloc]initWithPolyline:polyLine];
arender.strokeColor=[UIColor blueColor];
arender.lineWidth=3;
返回arender;
}
返回零;
}

现在,我想将该地图的详细信息保存到数据库中,并再次检索它,并将其显示为地图视图


提前谢谢。

您可以尝试每隔1或2秒向数据库发送一次lat long。然后用lat-long数组检索并重新绘制谢谢你的重播。你能给我提供示例代码或相关教程吗。