I have been provided with this address and told to find th开发者_如何学运维e current location of me
http://maps.google.com/maps/geo?q=address&output=csv
what kind of address is this and how can i get the information about this . Is this API ?
Please help
suppose if you give http://maps.google.com/maps/geo?q=newyork&output=csv, the result will be 200,4,40.7143528,-74.0059731.The last 2 values mean latitude and longitude value for New york...I hope it will help you.If you integrate this url in your app, you can get co-ordinates and use them to show the map in MKMapView in iPhone.
602,0,0,0
this is your location coordinates. and according to Google map you are located
hereWith that you can get latitude and longitude of an address. If you request this url and you use the address you want to find the coordinates you get 4 value as a response. You can use this function to get a Location object with lat and log of your address:
-(CLLocationCoordinate2D) addressLocation:(NSString *)address {
NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv",
[address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString]];
NSArray *listItems = [locationString componentsSeparatedByString:@","];
double latitude = 0.0;
double longitude = 0.0;
if([listItems count] >= 4 && [[listItems objectAtIndex:0] isEqualToString:@"200"]) {
latitude = [[listItems objectAtIndex:2] doubleValue];
longitude = [[listItems objectAtIndex:3] doubleValue];
}
else {
//Show error
}
CLLocationCoordinate2D location;
location.latitude = latitude;
location.longitude = longitude;
return location;
}
You can find more help here: http://mithin.in/2009/06/22/using-iphone-sdk-mapkit-framework-a-tutorial
精彩评论