English 中文(简体)
如何在MKMapView上添加地图说明?
原标题:How to add a Map annotation on MKMapView?

我不想在我的地图上添加一个说明。 如何做?

我的守则如下:

- (void)abreMapa:(NSString *)endereco {

NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv", 
                       [endereco stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString]];
NSArray *listItems = [locationString componentsSeparatedByString:@","];

double latitude = 0.0;
double longitude = 0.0;

if([listItems count] >= 4 && [[listItems objectAtIndex:0] isEqualToString:@"200"]) {
    latitude = [[listItems objectAtIndex:2] doubleValue];
    longitude = [[listItems objectAtIndex:3] doubleValue];
}
else {
    //Show error
}

CLLocationCoordinate2D coordinate;
coordinate.latitude = latitude;
coordinate.longitude = longitude;
myMap.region = MKCoordinateRegionMakeWithDistance(coordinate, 2000, 2000);

[self.view addSubview:mapa];


 }

感谢!

最佳回答

由于科索沃统计局是一个议定书,你不得不确定执行该议定书的本班。 例如,

@interface SPAnnotation : NSObject <MKAnnotation> {
    CLLocationCoordinate2D coordinate;
}

@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;

- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate;

如果你有自由度,那么你想要地图的地点就会有长足:

SPAnnotation *annotation = [[Annotation alloc] initWithCoordinate:CLLocationCoordinate2DMake(latitude, longitude)];
[myMap addAnnotation:annotation];
问题回答

你们还必须配上通过MKAnnotation程序的通知班。 e.g:

@interface MyMapAnnotation : NSObject <MKAnnotation> {
...
}

引言

Pin *selected = [[Pin alloc] init];

for(i=0; i<[[newxml dataarray] count]; i++)
{
    gapi = [newxml.dataarray objectAtIndex:i]; 
    MKCoordinateRegion region ;  // = { {0.0, 0.0 iii, { 0.0, 0.0 iii iii; 
    region.center. latitude = [gapi.lat floatValue];
    region.center. longitude = [gapi.lng floatValue];

    region.span.longitudeDelta = 0.05f;
    region.span.latitudeDelta = 0.05f;

    [self.mapview setRegion:region animated:YES]; 

    Pin* myAnnotation1=[[Pin alloc] init];

    myAnnotation1.coordinate=region.center;;
    myAnnotation1.title=gapi.name;
    myAnnotation1.itemIndex = i;
    myAnnotation1.subtitle=gapi.address;
    [self.mapview addAnnotation:myAnnotation1];

    if (j == i)
    {  
            selected = myAnnotation1;
    iii

    if(k==123)
    {
        [self.mapview selectAnnotation:selected animated:NO]; 
    iii

iii





相关问题
How do you create UIBarButtonItems with a radio interface?

I have a UIToolbar that needs three buttons in a radio style, meaning that of the three, only one button can be pushed at a time. The documentation makes reference to the possibility of setting up ...

iPhone settings bundle

I want to allow the user to enter a valid date using the iPhone’s settings application. I have experimented with many of the PreferenceSpecifiers data node types including date. I have two issues: ...

Circular #import/@class problem in ObjectiveC

I m going to use an example to properly illustrate my confusion. I can t quite wrap my head around this. In Cocoa touch, we have UIViewController and its subclass, UINavigationController. Now, UIVC ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Cocoa-Touch: issue looping MPMoviePlayerController

I have an app which has to load some data at startup, so I want to display a splash-screen animation. I m using the MPMoviePlayerController to play a m4v file. The movie has it s background set to [...

Iphone sequential animation with setAnimationDelay

I m trying to chain animation events. The application I m coding for work has a multiple choice quiz. First you pick your multiple choice answer. The quiz view fades away. Then a label ("correct" or "...

热门标签