how to change color of pin for mapview iphone
Asked Answered
E

1

0
MyAnnotation *ann1 = [[MyAnnotation alloc] init];

  ann1.coordinate =region.center;


  [mapView addAnnotation:ann1];

right now its purple i want red

Emogeneemollient answered 7/7, 2010 at 7:19 Comment(0)
M
2

Implement MKMapViewDelegate protocol callback and set the implementing class as the map view delegate

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation {

    MKPinAnnotationView *newAnnotationPin = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"simpleAnnotation"] autorelease];
    newAnnotationPin.pinColor = MKPinAnnotationColorRed; // Or Red/Green
    return newAnnotation;

}
Miniver answered 7/7, 2010 at 7:41 Comment(6)
thnkas and what about if i want to add 1 more red annotaion just say a distance of 5 m ahead form current pointEmogeneemollient
i want to show user current location and destination... right now i can show only destination plz help me to show current location in that map this is my dest codeEmogeneemollient
[code] NSString * theAddress = [myString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; NSString *urlString = [NSString stringWithFormat:@"maps.google.com/maps/geo?q=%@&output=csv", theAddress]; //NSString *urlString = [NSString stringWithFormat:@"maps.google.com/maps/geo?q=%g",daddr,saddr]; //NSLog(@" GEO44 is %@",urlString); NSString *locationString = [[[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:urlString]] autorelease]; NSLog(@" GEO MAP is %@",locationString); [/code]Emogeneemollient
NSString * theAddress = [myString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; NSString *urlString = [NSString stringWithFormat:@"maps.google.com/maps/geo?q=%@&output=csv", theAddress]; //NSString *urlString = [NSString stringWithFormat:@"maps.google.com/maps/geo?q=%g",daddr,saddr]; //NSLog(@" GEO44 is %@",urlString); NSString *locationString = [[[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:urlString]] autorelease]; NSLog(@" GEO MAP is %@",locationString);Emogeneemollient
You can show user location setting the showsUserLocation property to YES.Miniver
Could you be more precise ? How do you want the message to be displayed ?Miniver

© 2022 - 2024 — McMap. All rights reserved.