Place a pin on the location of the IOS touch

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.