views:

75

answers:

3

Hello Users,

I have a little (and I hope not hard, for you ) question:

How can I get the latitude and longtitude from mapView.userLocation?

I need that to get the distance between userLocation and another point on the map.

I hope you can help me and thank you beforehand!

Best Regards,

Marco

+1  A: 

Here is a similar question, hopefully with an answer that helps you out:

http://stackoverflow.com/questions/1449486/iphone-current-user-location-coordinates-showing-as-0-0

Matthias Vance
A: 

Use the method provided in CLLocation:

- (CLLocationDistance)getDistanceFrom:(const CLLocation *)location

Johan Kool
A: 

no sorry the similar question doesn't help i have readed this about 4 times.

yes i have the distance method but to get the distance i need the coordinates of userLocation, look this is my code:

- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation{

    Koordinate *testUser = [eventPoints objectAtIndex:1];
    CLLocation *testUserLoc = [[CLLocation alloc] initWithLatitude:testUser.latitude longitude:testUser.longtitude];
    Koordinate *kunde = [[Koordinate alloc] init];
    kundenPoints = [[NSMutableArray array] retain];

    for(int i = 0; i<[eventPoints count]; i++){
        kunde = [eventPoints objectAtIndex:i];
        CLLocation *userLoc = [[CLLocation alloc] initWithLatitude:kunde.latitude longitude:kunde.longtitude];
        double distance = [testUserLoc getDistanceFrom:userLoc] / 1000;
        if(distance <= 100){
            [kundenPoints addObject:kunde];
        }else {
        }
    }
    [mapView addAnnotations:kundenPoints];
}

actual it is testUser but excpect testUser i need my userLocation????

I hope you could help me again?

Marco
You just got your user's location passed in through the `newLocation` parameter. What is the problem?
Johan Kool
Oh thank you great, i don't know that!Thank you for helping me!
Marco