Add multiple pins on the Ios gold map How do I know which pin I clicked in the multiplexing queue?

Source: Internet
Author: User

Create a Pin object     MAPointAnnotation *pointAnnotation = [[MAPointAnnotation  alloc] init];    //where to insert the pin     pointannotation.coordinate =  cllocationcoordinate2dmake (39.989631, 116.481018);     //pin title      pointannotation.title = @ "Fang Heng International";     //pin sub-title      pointannotation.subtitle = @ "No. 6th, Fu Tong East Street";     [_mapview addannotation: Pointannotation];//The following methods can make the map pin pop-up bubble-  (maannotationview *) Mapview: (mamapview *) mapview  Viewforannotation: (id <maannotation>) annotation{    if  ([annotation  Iskindofclass:[mapointannotation class]])     {         static nsstring *pointreuseindetifier = @ "Pointreuseindetifier";         MAPinAnnotationView*annotationView =  (mapinannotationview*) [mapview  dequeuereusableannotationviewwithidentifier:pointreuseindetifier];         if  (Annotationview == nil)         {             annotationview = [[mapinannotationview  alloc] initWithAnnotation:annotation reuseIdentifier:pointReuseIndetifier];         }        annotationview.canshowcallout=  yes;       //set bubbles can pop up, default is no         annotationview.animatesdrop = yes;        //Set the callout animation display, Default is no        annotationview.draggable = yes;         //setting annotations can beDrag, default to no        annotationview.pincolor =  mapinannotationcolorpurple;        return annotationview;             }    return nil;} Use coordinate information to judge     you didn't say the exact effect you wanted    I'll tell you one.    suppose you have n pins on the map    In fact, that is, n pointannotation   you can get to   directly by _mapview.annotations This is the array    in the method of clicking the Pin-  ( void) Mapview: (bmkmapview *) Mapview didselectannotationview: (bmkannotationview *) View{NSArray  * array = [nsarray arraywitharray:_mapview.annotations];    for   (int i=0; i<array.count; i++)     {         if  (view.annotation.coordinate.latitude == (bmkpointannotation*) array[i]). Coordinate.latitude) &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSp {            //gets to the current pin    You can do some things         }        else         {             //operation of the remaining pins    I was deleting             //[ _mapview removeannotation:array[i]];        }     }}


This article is from the "zhuoking" blog, make sure to keep this source http://9951038.blog.51cto.com/9941038/1764185

Add multiple pins on the Ios gold map How do I know which pin I clicked in the multiplexing queue?

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.