我已经提供了该地址,并告诉我找如何获得当前位置?
http://maps.google.com/maps/geo?q=address&output=csv
的当前位置是什么样的地址是这样的,我怎么能得到这个信息。这是API吗?
请帮
我已经提供了该地址,并告诉我找如何获得当前位置?
http://maps.google.com/maps/geo?q=address&output=csv
的当前位置是什么样的地址是这样的,我怎么能得到这个信息。这是API吗?
请帮
想,如果你给http://maps.google.com/maps/geo?q=newyork&output=csv,其结果将是 200, 4,40.7143528,-74.0059731。最后2个值表示纽约的经度和纬度值...我希望它能帮助你。如果你把这个URL集成到你的应用中,你可以获得坐标并用它们来显示在iPhone中的MKMapView地图。
602,0,0,0
这是你的位置坐标。并根据谷歌地图你位于这里
由于你可以得到一个地址的经度和纬度。如果您请求此网址并使用您想要查找坐标的地址,则可以获得4个值作为响应。您可以使用此功能来获得一个位置的对象与纬度和记录您的地址:
-(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;
}
你可以找到更多的帮助,在这里:http://mithin.in/2009/06/22/using-iphone-sdk-mapkit-framework-a-tutorial
你怎么知道OP的位置? :) – AbdullahC 2011-04-21 06:41:34
没有人在地址位置键入ur地址和csv格式写在你想要的结果像json等格式 – Exception 2011-04-21 06:44:28
现在什么是OP? – 2011-04-21 06:44:55