簡體   English   中英

MapView顯示最多3個注釋

[英]MapView shows max 3 annotations

這里真的很奇怪。

我添加了4個注釋(或者,我嘗試過很多次,分別是15個或20個),但在地圖上(隨機顯示)最多只能顯示2個或最多3個。

這是來源:

//  [self showRealEstates];
    CLLocationCoordinate2D theCoordinate1;
    theCoordinate1.latitude = 37.786996;
    theCoordinate1.longitude = -122.419281;

    CLLocationCoordinate2D theCoordinate2;
    theCoordinate2.latitude = 37.810000;
    theCoordinate2.longitude = -122.477989;

    CLLocationCoordinate2D theCoordinate3;
    theCoordinate3.latitude = 37.760000;
    theCoordinate3.longitude = -122.447989;

    CLLocationCoordinate2D theCoordinate4;
    theCoordinate4.latitude = 37.80000;
    theCoordinate4.longitude = -122.407989;

    MapAnnotationRealEstate* myAnnotation1=[[MapAnnotationRealEstate alloc] initWithCoordinate:theCoordinate1 andTitle:@"Rohan"];

    MapAnnotationRealEstate* myAnnotation2=[[MapAnnotationRealEstate alloc] initWithCoordinate:theCoordinate2 andTitle:@"Vaibhav"];

    MapAnnotationRealEstate* myAnnotation3=[[MapAnnotationRealEstate alloc] initWithCoordinate:theCoordinate3 andTitle:@"Rituraj"];

    MapAnnotationRealEstate* myAnnotation4=[[MapAnnotationRealEstate alloc] initWithCoordinate:theCoordinate4 andTitle:@"Sahil"];

    NSMutableArray * annotations = [[NSMutableArray alloc] init];
    [annotations addObject:myAnnotation1];
    [annotations addObject:myAnnotation2];
    [annotations addObject:myAnnotation3];
    [annotations addObject:myAnnotation4];

    [mapView addAnnotations:annotations];
//  [mapView addAnnotation:myAnnotation1];
//  [mapView addAnnotation:myAnnotation2];
//  [mapView addAnnotation:myAnnotation3];
//  [mapView addAnnotation:myAnnotation4];

    NSLog(@"annotations: %d", [mapView annotations].count);

最后的日志顯示2或3。不知道該怎么做,我盡可能地簡化了示例,以消除其他因素,但仍然可以做到這一點。

正如我們所看到的,這兩個緯度/經度很接近。 我相信所有注釋都已繪制在地圖上,並且您無法從當前縮放級別看到。

CLLocationCoordinate2D theCoordinate1;
theCoordinate1.latitude = 37.786996;
theCoordinate1.longitude = -122.419281;

CLLocationCoordinate2D theCoordinate4;
theCoordinate4.latitude = 37.80000;
theCoordinate4.longitude = -122.407989;

它們似乎在縮小視圖的地圖視圖中重疊。 嘗試將地圖放大到最大級別,我相信您會看到所有4條注釋。

或者您可以嘗試更改這些注釋之一的緯度/經度。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM