Iphone 显示从当前位置到移动车辆目的地的路线

Iphone 显示从当前位置到移动车辆目的地的路线,iphone,objective-c,google-maps,gps,Iphone,Objective C,Google Maps,Gps,我尝试使用谷歌地图显示从当前位置到目的地的路线,但我想显示从移动对象到当前位置的路线?我希望您能找到一种方法,通过以下URL实现您的功能 使用类似于 (MKAnnotationView*)地图视图:(MKMapView*)地图视图注释:(id)注释{ if([annotation isKindOfClass:[NVPolylineAnnotation class]]){ } 返回零; } (void)地图视图:(MKMapView*)地图视图添加注释视图:(NSArray*)视图{ //修复了

我尝试使用谷歌地图显示从当前位置到目的地的路线,但我想显示从移动对象到当前位置的路线?

我希望您能找到一种方法,通过以下URL实现您的功能


使用类似于

  • (MKAnnotationView*)地图视图:(MKMapView*)地图视图注释:(id)注释{

    if([annotation isKindOfClass:[NVPolylineAnnotation class]]){

    }

    返回零; }

  • (void)地图视图:(MKMapView*)地图视图添加注释视图:(NSArray*)视图{

    //修复了某些标记位于多段线后面的问题 如果([Appdelegate.CrashUserArray计数]>0) {

    对于(int i=0;i<[Appdelegate.CrashUserArray计数];i++) {

    } } -(void)mapView:(MKMapView*)aMapView didUpdateUserLocation:(MKUserLocation*)aUserLocation{

    协调区域; Mk坐标跨度; span.latitudeDelta=0.005; span.longitudeDelta=0.005

    oldlocation.latitude=aUserLocation.coordinate.latitude; oldlocation.longitude=aUserLocation.coordinate.longitude; region.span=span; region.center=旧位置

    NSArray*点=[NSArray arrayWithObjects: [[CLLocation alloc]INITWITH纬度:45.43894经度:-73.7396]自动释放], [[CLLocation alloc]INITWITH纬度:45.44628经度:-73.74119]自动释放], [[CLLocation alloc]initWithLatitude:45.44649经度:-73.741069999999]自动释放], [[CLLocation alloc]initWithLatitude:45.44665999999经度:-73.7409]自动释放], [[CLLocation alloc]initWithLatitude:45.44665999999经度:-73.7409]自动释放], [[CLLocation alloc]INITWITH纬度:45.44676经度:-73.74073]自动释放], [[CLLocation alloc]initWithLatitude:45.4470799999999经度:-73.7399000000001]自动释放], [[CLLocation alloc]INITWITH纬度:45.44748经度:-73.73856000000001]自动释放], [[CLLocation alloc]INITWITH纬度:45.44748经度:-73.73856000000001]自动释放], [[CLLocation alloc]INITWITH纬度:45.44834经度:-73.73581]自动释放], [[[CLLocation alloc]initWithLatitude:45.448579999999经度:-73.7347599999999]自动释放], [[CLLocation alloc]INITWITH纬度:45.44863000000001经度:-73.734170000001]自动释放], [[[CLLocation alloc]INITWITH纬度:45.44863000000001经度:-73.73300999999]自动释放], [[CLLocation alloc]INITWITH纬度:45.44795经度:-73.7008]自动释放], [[CLLocation alloc]INITWITH纬度:45.44784经度:-73.69398]自动释放], [[CLLocation alloc]INITWITH纬度:45.44775经度:-73.690900000001]自动释放], [[CLLocation alloc]INITWITH纬度:45.447439999999经度:-73.68584]自动释放], [[CLLocation alloc]INITWITH纬度:45.44728经度:-73.6816599999999]自动释放]

                       [[[CLLocation alloc] initWithLatitude:45.48679000000001 longitude:-73.59443] autorelease],
                       nil];
    
    NVPolylineAnnotation *annotation = [[[NVPolylineAnnotation alloc] initWithPoints:points mapView:map] autorelease];
    
    
    [map addAnnotation:annotation];
    
    
    [loc release];
    [aMapView setRegion:region animated:YES];
    NSLog(@"uncomment this when you want to upload record");
    
    } }

用这种方法你们可以在地图上画出路径

for (int j = 0; j < [views count]; j++) {

    MKAnnotationView *view = [views objectAtIndex:j];

    if ([view isKindOfClass:[NVPolylineAnnotationView class]])

    {

        [[view superview] sendSubviewToBack:view];

        //view.image=[UIImage imageNamed:@"close_button.png"];

        NSString *reqSysVer = @"4.0";

        NSString *currSysVer = [[UIDevice currentDevice] systemVersion];

        if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)

        {

            [self updatePolylineAnnotationView];

        }

    }

    else {

        if ([[Appdelegate.CrashUserArray objectAtIndex:i] count] > 0) {

            nextviewbtn=[[UIButton alloc]init];

            nextviewbtn.frame=CGRectMake(10,10,13,22);

            [nextviewbtn addTarget:self action:@selector(OpenUser:) forControlEvents:UIControlEventTouchUpInside];

            nextviewbtn.tag=i;

            [nextviewbtn setBackgroundImage:[UIImage imageNamed:@"right_arrow.png"] forState:UIControlStateNormal];

            dispatch_async(dispatch_get_global_queue(0,0), ^{

                NSData * data = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString: [[[Appdelegate.CrashUserArray objectAtIndex:i]objectAtIndex:0] objectForKey:@"userphoto_47"]]];

                if ( data == nil )

                    return;

                dispatch_async(dispatch_get_main_queue(), ^{



                    view.image = [UIImage imageWithData: data];

                    view.rightCalloutAccessoryView=nextviewbtn;

                });

                [data release];

            });

        }

    }

}
RegionAnnotationView *regionView = (RegionAnnotationView *)annotationView;

RegionAnnotation *regionAnnotation = (RegionAnnotation *)regionView.annotation;



if (newState == MKAnnotationViewDragStateStarting) {

    [regionView removeRadiusOverlay];

    [locationmanager stopMonitoringForRegion:regionAnnotation.region];

}

if (oldState == MKAnnotationViewDragStateDragging && newState == MKAnnotationViewDragStateEnding) {

    [regionView updateRadiusOverlay];

    NSUserDefaults *def=[NSUserDefaults standardUserDefaults];

    CLRegion *newRegion = [[CLRegion alloc] initCircularRegionWithCenter:regionAnnotation.coordinate radius:1000.0 identifier:[NSString stringWithFormat:@"%f, %f", [def floatForKey:@"currentlati"],[def floatForKey:@"currentlongi"]]];

    regionAnnotation.region = newRegion;

    // [locationmanager startMonitoringForRegion:regionAnnotation.region desiredAccuracy:kCLLocationAccuracyBest];
}
                   [[[CLLocation alloc] initWithLatitude:45.48679000000001 longitude:-73.59443] autorelease],
                   nil];

NVPolylineAnnotation *annotation = [[[NVPolylineAnnotation alloc] initWithPoints:points mapView:map] autorelease];


[map addAnnotation:annotation];


[loc release];
[aMapView setRegion:region animated:YES];
NSLog(@"uncomment this when you want to upload record");