Is there any way to get the lat long of MKMapView of touch position - iPhone SDK

…衆ロ難τιáo~ 提交于 2019-12-14 00:25:10

问题


How to get the latitude and longitude of touch position on map view?

I want to drop a pin where user touches just like google's javascript API does.

Is it possible in iphone SDK? Tutorial would be a great help.


回答1:


MKMapView has a method, - (CLLocationCoordinate2D)convertPoint:(CGPoint)point toCoordinateFromView:(UIView *)view that can be used to get the longitude and latitude that any specified point would fall on.

To get the touch position, if you're fine with limiting yourself to iOS 3.2 and above, by far the easiest thing to do is to add a UITapGestureRecognizer to the relevant MKMapView.




回答2:


assuming the current lan/long is the center of the screen ...
know the distance between the touch position and the center of the screen + know each pixel how many hours/degrees and some simple calculation you will get the lat/long of the touch position you might get the degrees/hours per pixel from the zoom level maybe ?

am not an iphone guy , but this is an idea that might help :p



来源:https://stackoverflow.com/questions/4806628/is-there-any-way-to-get-the-lat-long-of-mkmapview-of-touch-position-iphone-sdk

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