Iphone 从MapView中选择位置
我在考虑一个应用程序,用户可以在iphone应用程序上选择一个位置。我在谷歌上搜索了一下,没有发现任何有用的东西 我的问题是,是否可以让用户使用MapKit/CLLocation从iphone应用程序中选择位置?如果是,请帮助我从哪里开始Iphone 从MapView中选择位置,iphone,objective-c,xcode,mapkit,cllocation,Iphone,Objective C,Xcode,Mapkit,Cllocation,我在考虑一个应用程序,用户可以在iphone应用程序上选择一个位置。我在谷歌上搜索了一下,没有发现任何有用的东西 我的问题是,是否可以让用户使用MapKit/CLLocation从iphone应用程序中选择位置?如果是,请帮助我从哪里开始 谢谢看一看。答案不仅告诉您如何获取坐标,还告诉您如何在地图上放置pin(注释)。您可以在地图上添加长按手势识别器: UILongPressGestureRecognizer* lpgr = [[UILongPressGestureRecognizer allo
谢谢看一看。答案不仅告诉您如何获取坐标,还告诉您如何在地图上放置pin(注释)。您可以在地图上添加长按手势识别器:
UILongPressGestureRecognizer* lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
lpgr.minimumPressDuration = 1.5;
lpgr.delegate = self;
[self.map addGestureRecognizer:lpgr];
[lpgr release];
在handle long press方法中,获取CLLocationCordinate2D:
- (void) handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer {
if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
/*
Only handle state as the touches began
set the location of the annotation
*/
CLLocationCoordinate2D coordinate = [self.map convertPoint:[gestureRecognizer locationInView:self.map] toCoordinateFromView:self.map];
[self.map setCenterCoordinate:coordinate animated:YES];
// Do anything else with the coordinate as you see fit in your application
}
}