Search code examples
iphonegoogle-mapssmsmapkitmessageui

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!


Solution

  • 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.