Krismutt
Krismutt

Reputation: 191

Send user location coordinates to SMS.app as an googleMaps-link

I wanna send my location coordinates as a Google Maps link (http://maps.google.com/?saddr=%1.6f,%1.6f) as an SMS but i just can't get it to work... How should I do so that the GoogleMaps-link varies to my location??

MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];

        controller.body = @"This is my location http://maps.google.com/?saddr=%1.6f,%1.6f";

    NSString *googleMaps = [NSString stringWithFormat:@"http://maps.google.com/?saddr=%1.6f,%1.6f", location.latitude, location.longitude];

    controller.recipients = [NSArray arrayWithObjects:nil];
            controller.messageComposeDelegate = self;
            [self presentModalViewController:controller animated:YES];  
            }
    }

Any ideas? Would really appreciate an answer!!!!

Thanks you and happy holidays!

Upvotes: 2

Views: 2092

Answers (2)

nickthedude
nickthedude

Reputation: 4973

shouldn't you have:

controller.body = [NSString stringWithFormat:@"http://maps.google.com/?saddr=%1.6f,%1.6f", location.latitude, location.longitude];

you're hard coding the body and then creating an unrelated string which is probably properly formatted and never doing anything with it.

Upvotes: 3

nickthedude
nickthedude

Reputation: 4973

you need to do location.coordinate.latitude, location.coordinate.longitude assuming location is a cllocation object.

Upvotes: 0

Related Questions