Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-27-2012, 11:07 AM   #1 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 1
djmoses is on a distinguished road
Default Mapkit new annotations with pin without popup

Hello! i've just created a new app, and i've implemented a map in a view.
I've created the map with some personal annotation but, when the user touch the pin, doesn't appear anything. I've tried to set the colour of the pin but nothing seem's to work. I need that the user, when touch the pin, can touch the disclosure button on the popup, to use "native maps".
Now, when i touch the pin, this one become darker, but nothing else.
Can someone help me? Please!!

io ne avrei bisogno, per far aprire poi un disclosure e far aprire l'app nativa mappe per creare il percorso!! Se ora tocco il pin, questo diventa pił scuro ma non succede nulla! non riesco nemmeno ad agire su di loro per cambiare colore, immagini,.... ho guardato i tutorial ma non trovo l'errore!


header subclass


Code:
 #import <Foundation/Foundation.h>
    #import <MapKit/Mapkit.h>

    @interface myAnnotation : NSObject <MKAnnotation>{
        
        CLLocationCoordinate2D coordinate;
        NSString *titolo;
        NSString *sottotitolo;
    }

    @property(nonatomic,assign) CLLocationCoordinate2D coordinate;
    @property(nonatomic,copy) NSString *titolo;
    @property(nonatomic,copy) NSString *sottotitolo;


    @end
implementation subclass


Code:
 @implementation myAnnotation

    @synthesize titolo;
    @synthesize sottotitolo;
    @synthesize coordinate;

    -init{
        return self;
        
    }

    @end
file .m view controller


Code:
CLLocation *userLoc = myMapView.userLocation.location;
        CLLocationCoordinate2D userCoordinate = userLoc.coordinate;
    	NSLog(@"user latitude = %f",userCoordinate.latitude);
    	NSLog(@"user longitude = %f",userCoordinate.longitude);
    	myMapView.delegate=self;

        
        NSMutableArray* annotations=[[NSMutableArray alloc] init];
       
    	CLLocationCoordinate2D theCoordinate1;
        theCoordinate1.latitude = 45.;
        theCoordinate1.longitude = 7.;

    	CLLocationCoordinate2D theCoordinate2;
        theCoordinate2.latitude = 45.;
        theCoordinate2.longitude = 12.;
     
    	CLLocationCoordinate2D theCoordinate3;
        theCoordinate3.latitude = 45.;
        theCoordinate3.longitude = 8.;
     
    	CLLocationCoordinate2D theCoordinate4;
        theCoordinate4.latitude = 43.;
        theCoordinate4.longitude = 7.;
        
    	myAnnotation* myAnnotation1=[[myAnnotation alloc] init];
        
    	myAnnotation1.coordinate=theCoordinate1;
    	myAnnotation1.titolo=@"xxxx";
    	myAnnotation1.sottotitolo=@"xxx";
      
        
    	myAnnotation* myAnnotation2=[[myAnnotation alloc] init];
        
    	myAnnotation2.coordinate=theCoordinate2;
    	myAnnotation2.titolo=@"yyyy";
    	myAnnotation2.sottotitolo=@"yyyy";
        
        myAnnotation* myAnnotation3=[[myAnnotation alloc] init];
        
    	myAnnotation3.coordinate=theCoordinate3;
    	myAnnotation3.titolo=@"zzz";
    	myAnnotation3.sottotitolo=@"zzz";
        
    	myAnnotation* myAnnotation4=[[myAnnotation alloc] init];
        
    	myAnnotation4.coordinate=theCoordinate4;
    	myAnnotation4.titolo=@"kkk";
    	myAnnotation4.sottotitolo=@"kkk";
        
    	    
    	[myMapView addAnnotation:myAnnotation1];
    	[myMapView addAnnotation:myAnnotation2];
        [myMapView addAnnotation:myAnnotation3];
    	[myMapView addAnnotation:myAnnotation4];
    	
        
    	[annotations addObject:myAnnotation1];
    	[annotations addObject:myAnnotation2];
        [annotations addObject:myAnnotation3];
    	[annotations addObject:myAnnotation4];
    	
        
        NSLog(@"%d",[annotations count]);
and then this snippet to show and personalize the pin
Code:
-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:
(id <MKAnnotation>)annotation {
    MKPinAnnotationView *pinView = nil; 
    if(annotation != mapView.userLocation) 
    {
        static NSString *defaultPinID = @"com.invasivecode.pin";
        pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
        if ( pinView == nil ) pinView = [[[MKPinAnnotationView alloc]
                                          initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];

        pinView.pinColor = MKPinAnnotationColorPurple; 
        pinView.canShowCallout = YES;
        pinView.animatesDrop = YES;
    } 
    else {
        [mapView.userLocation setTitle:@"I am here"];
    }
    return pinView;
}
Thank You!
djmoses is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 408
10 members and 398 guests
Atatator, condor304, FrankWeller, imac74, MAMN84, mraalex, n00b, PowerGoofy, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,674
Threads: 94,123
Posts: 402,908
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Atatator
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:57 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0