As we know that When we use the Google Map with iphone and Annotation with that it always drop a/any number of pin on the Map View. it is Good But we can Make it More interested and Feel Good.
That can be done by replacing the pin with Any Image such as we want to get friends location on map and we replace friends pin with there Image then its look so much feel good and by that u can know who is that without any click or touch on screen.
That can be Done by inheriting MKAnnotationView.
Follow such code:
MyPinAnnotation *annview = [[MyPinAnnotation alloc] initWithAnnotation:annotation]; //reuseIdentifier:@"CustomId"];
annview.frame = CGRectMake(0, 0, 25, 25);
[annview setCanShowCallout:YES];
[annview setSelected:YES];
return annview;
That code will be written in
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id) annotation
function of Map.
Now implement the .h and .m file of MyPinAnnotation which inheriting MKAnnotationView class
.h file
#import
#import
@interface MyPinAnnotation : MKAnnotationView {
}
- (id)initWithAnnotation:(id) annotation;
@end
.m file
#import "MyPinAnnotation.h"
@implementation MyPinAnnotation
- (id)initWithAnnotation:(id)annotation
{
self = [super initWithAnnotation:annotation reuseIdentifier:@"CustomId"];
if (self)
{
UIImage* theImage = [UIImage imageNamed:@"1.jpeg"];
if (!theImage)
return nil;
self.image = theImage;
}
return self;
}
- (void)dealloc {
[super dealloc];
}
@end
Use it And Happy programming : Keep Smiling :-> with full of Fun
Thanks
That can be done by replacing the pin with Any Image such as we want to get friends location on map and we replace friends pin with there Image then its look so much feel good and by that u can know who is that without any click or touch on screen.
That can be Done by inheriting MKAnnotationView.
Follow such code:
MyPinAnnotation *annview = [[MyPinAnnotation alloc] initWithAnnotation:annotation]; //reuseIdentifier:@"CustomId"];
annview.frame = CGRectMake(0, 0, 25, 25);
[annview setCanShowCallout:YES];
[annview setSelected:YES];
return annview;
That code will be written in
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id
function of Map.
Now implement the .h and .m file of MyPinAnnotation which inheriting MKAnnotationView class
.h file
#import
#import
@interface MyPinAnnotation : MKAnnotationView {
}
- (id)initWithAnnotation:(id
@end
.m file
#import "MyPinAnnotation.h"
@implementation MyPinAnnotation
- (id)initWithAnnotation:(id
{
self = [super initWithAnnotation:annotation reuseIdentifier:@"CustomId"];
if (self)
{
UIImage* theImage = [UIImage imageNamed:@"1.jpeg"];
if (!theImage)
return nil;
self.image = theImage;
}
return self;
}
- (void)dealloc {
[super dealloc];
}
@end
Use it And Happy programming : Keep Smiling :-> with full of Fun
Thanks
No comments:
Post a Comment