【问题标题】:get location from iphone mapview从 iphone mapview 获取位置
【发布时间】:2010-07-24 03:16:29
【问题描述】:

我正在 iphone 中做一个基于地图的应用程序,我需要获取地图视图中心的位置。当用户拖动/移动/缩放地图视图时,我需要更新位置。这样我就可以从地图中获取纬度/经度信息,并将这些信息发送到google api以获取地址信息。

任何人都知道如何实现这一点吗?请帮忙。

提前致谢 世斌男

【问题讨论】:

  • 您能否指定这段代码的哪一部分应该写在.h 中,哪一部分应该写在.m 中,几乎没有代码解释。很抱歉问了更多问题,但我对所有这些事情都很陌生,并且很难理解代码。谢谢,

标签: iphone location mkmapview


【解决方案1】:

要从 google api 获取地址信息,您必须使用 reverseGeocoder。

在这里你传递你的纬度/经度。

MKReverseGeocoder *reverseGeocoder = [[MKReverseGeocoder alloc] initWithCoordinate:newLocation.coordinate];
reverseGeocoder.delegate = self;    
[reverseGeocoder start];

在这里你可以得到地址信息

-(void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark
{
    NSDictionary *address = [[NSDictionary alloc]initWithDictionary:placemark.addressDictionary];       
    NSLog(@"%@",address);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多