Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get part of the map view as an image in iOS

Tags:

image

iphone

I am creating an app where in I have to show just the part of the area where on my place will be plotted, Similar like the one below.

MAp part

Clicking on this will image will take my app further. But here it's just an static image generated depending upon my longitude and latitude.

Any help would be really appreciated. Thanks

like image 976
Suresh Varma Avatar asked Aug 24 '11 12:08

Suresh Varma


1 Answers

Here's the working code. Incase anybody's still searching out for the answer.

NSString *staticMapUrl = [NSString stringWithFormat:@"http://maps.google.com/maps/api/staticmap?markers=color:red|%f,%f&%@&sensor=true",yourLatitude, yourLongitude,@"zoom=10&size=270x70"];    
NSURL *mapUrl = [NSURL URLWithString:[staticMapUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; 
UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:mapUrl]];

Thanks

like image 60
Suresh Varma Avatar answered Jan 01 '23 20:01

Suresh Varma