开发者

Two annotations which are not both displayed on the map

in my app, i try to display two annotations representing each one a specific longitude/latitude, my relevant code is this :

-(void)viewWillAppear:(BOOL)animated{
    currentLocation.latitude=33.413313;
    currentLocation.longitude=-111.907326;

    currentLocation2.latitude=32.413313;
    currentLocation2.longitude=-110.907326;

    RMMarkerManager *markerManager=[mapView markerManager];
    [mapView setDelegate:self];
    [mapView setBackgroundColor:[UIColor grayColor]];
    [mapView moveToLatLong:currentLocation];
    [self.view addSubview:mapView];
    RMMarker *marker=[[RMMarker alloc] initWithUIImage:[UIImage imageNamed:@"marker-blue.png"]];
    [marker setTextForegroundColor:[UIColor blueColor]];
    [marker changeLabelUsingText:@"Vous êtes ici"];
    [markerManager addMarker开发者_如何学编程:marker
                   AtLatLong:currentLocation];

    RMMarker *marker2=[[RMMarker alloc] initWithUIImage:[UIImage imageNamed:@"marker-red.png"]];
    [marker setTextForegroundColor:[UIColor redColor]];
    [marker changeLabelUsingText:@"Station de service"];
    [markerManager addMarker:marker2
                   AtLatLong:currentLocation2];



    [marker release];
    [marker2 release];

}

After i run the app, i see only one annotation :

Two annotations which are not both displayed on the map

The strange is that the only annotation i see has the color of the first annotation and the text of the second annotation.


In your code, when setting the color and text of the second marker you seem to have a typo where you've forgotten the '2' so you are actually setting the color and text on the first marker twice. That probably explains why it has the color of one and text of the other, but I'm not sure it explains why only one appears on the map.

edit: I think the reason that they are not both appearing on the map is that the two points are one degree of latitude and one degree of longitude apart, which is basically over 100km distance - which looks much larger than the zoom scale of the map section you are showing. Maybe you meant to have them one minute apart rather than one degree (which would translate to a couple of km rather than over 100km).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜