如何显示我的当前位置(GPS)在mapview



我成功地从教程中获取了我当前位置的经纬度。我想把这个集成到mapview中这样mapview中就会有一个蓝色指示器。我知道mapview在添加注释方面的基础知识,但如何集成我的当前位置。如果你们能给我举个例子我就太好了。代码如下:

- (void)locationUpdate:(CLLocation *)location {
speedLabel.text = [NSString stringWithFormat:@"SPEED: %f", [location speed]];
latitudeLabel.text = [NSString stringWithFormat:@"LATITUDE: %f", location.coordinate.latitude];
longitudeLabel.text = [NSString stringWithFormat:@"LONGITUDE: %f", location.coordinate.longitude];
altitudeLabel.text = [NSString stringWithFormat:@"ALTITUDE: %f", [location altitude]];
NSLog(@"will dis :%d",location.coordinate.latitude);

}

在地图上显示用户当前位置的蓝色指示器非常简单。把

[self.mapView setShowsUserLocation:YES];

在包含MKMapView的ViewController上。

另外,设置mapView的区域在你当前位置附近也是很有用的。要了解更多信息,请查看Apple的示例

最新更新