Getting current location of map on touch in iphone mkmapview

杀马特。学长 韩版系。学妹 提交于 2019-12-10 14:56:06

问题


How can I get the location coordinates in mkmapview according to user touching a location on the map on their iphone?


回答1:


Add TapGesture to you mapview and follow below code

-(void)didTouchMap:(UITapGestureRecognizer*)tapGesure {

         CGPoint touchPoint = [tapGesure locationInView:selectLocationMapView];
         CLLocationCoordinate2D coord= [selectLocationMapView convertPoint:touchPoint      toCoordinateFromView:selectLocationMapView];
         NSLog(@"lat  %f",coord.latitude);
         NSLog(@"long %f",coord.longitude);

}


来源:https://stackoverflow.com/questions/6449949/getting-current-location-of-map-on-touch-in-iphone-mkmapview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!