Place a pin on the location of the IOS touch
UITapGestureRecognizer *mtap = [[UITapGestureRecognizer alloc] initwithtarget:self action: @selector (tappress:)];
[Self.mapview Addgesturerecognizer:mtap];
The event is implemented as follows:
[CPP] View plaincopyprint?
-(void) Tappress: (uigesturerecognizer*) Gesturerecognizer {
Cgpoint touchPoint = [Gesturerecognizer locationinview:_mapview];//here TouchPoint is the location of the clicked Point in the map control
Cllocationcoordinate2d touchmapcoordinate =
[_mapview convertpoint:touchpoint tocoordinatefromview:_mapview];//here touchmapcoordinate is the latitude and longitude of this point
NSLog (@ "Touching%f,%f", touchmapcoordinate.latitude,touchmapcoordinate.longitude);
Cllocationcoordinate2d Location=cllocationcoordinate2dmake (Touchmapcoordinate.latitude, Touchmapcoordinate.longitude);
Kcannotation *annotation=[[kcannotation Alloc]init];
[Email protected] "Kenshin&kaoru";
[Email protected] "Kenshin Cui ' s Home";
Annotation.coordinate=location;
Annotation.image=[uiimage imagenamed:@ "Icon_paopao_waterdrop_streetscape.png"];
Annotation.icon=[uiimage imagenamed:@ "Icon_mark2.png"];
[Email protected] "Kenshin Cui ...";
Annotation2.rate=[uiimage imagenamed:@ "Icon_movie_star_rating.png"];
[_mapview Addannotation:annotation2];
}
Place a pin on the location of the IOS touch