I have latitude and longitude which is to be converted to x,y coordinates.I want to subview an image to that point
Asked
Active
Viewed 1,554 times
3
-
Could you be a little more descriptive? Are you trying to convert a lat / lng on a MKMapView to x / y screen points (CGPoint)? If so, you can do a `- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{ CLLocationCoordinate2D coord= [map convertPoint:point toCoordinateFromView:map]; NSLog(@"lat %f",coord.latitude); NSLog(@"long %f",coord.longitude); [ADD IMAGE HERE VIA ANNOTATION USING LAT LNG] return [super hitTest:point withEvent:event]; }` – a1phanumeric Dec 20 '12 at 21:40
-
@a1phanumeric I can retrieve the latitude and longitude if I touch on MKMapView.I need to convert that latitude and longitude to CGPoint. – Aswathy Bose Dec 21 '12 at 08:09
-
1Hello, why not use something like `CGPoint point = [self.mapView convertCoordinate:coord toPointToView:self.mapView];` – a1phanumeric Dec 21 '12 at 09:04
-
@a1phanumeric:Thanks yaar...it works... – Aswathy Bose Dec 21 '12 at 11:32
-
possible duplicate of [iPhone SDK: Convert MKMapPoint to CGPoint](http://stackoverflow.com/questions/4129322/iphone-sdk-convert-mkmappoint-to-cgpoint) – CRDave Apr 14 '14 at 11:47