Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Point touch with zoom mapView

I'm trying to catch a coordinate from touch event. I can catch but when give zoom have big numbers and when I put this in a function

newCoord = [mapView convertPoint:location toCoordinateFromView:mapView],

I get wrong coordinates. What can I do?

My code:

UITouch *touch = [touches anyObject];

CGPoint location = [touch locationInView:touch.view];


NSLog(@"locationTOUCH:%f,%f", location.x,location.y);

CLLocationCoordinate2D newCoord;

newCoord = [mapView convertPoint:location toCoordinateFromView:mapView];

NSLog(@"coordinate-%f,%f", newCoord.latitude,newCoord.longitude); 
like image 435
vijay adhikari Avatar asked Jul 28 '11 05:07

vijay adhikari


1 Answers

I'd guess it should be fixed by changing

CGPoint location = [touch locationInView:touch.view];

to

CGPoint location = [touch locationInView:mapView];
like image 109
Ortwin Gentz Avatar answered Oct 17 '22 16:10

Ortwin Gentz