【问题标题】:Display spiderfy leaflet annotation MKMapView显示 spiderfy 传单注释 MKMapView
【发布时间】:2014-05-08 12:35:15
【问题描述】:

我想在相同的经纬度上使用 MKMapView 显示 100 个地图点。请参阅link

我想在 iphone 上做同样的事情。

【问题讨论】:

  • 请检查我想使用 spiderfy Leafleft 动画显示的这个链接。 yourmapper.com/demo/spiderfy.htm。当我使用正常过程时,地图点相互重叠,无法单击特定地图点。所以通过使用 spiderfy 动画,我们可以实现这一点。任何想法。
  • 最后我找到了使用 Jquery+HTML 的解决方案。

标签: ios objective-c google-maps-api-3 mapkit


【解决方案1】:

如果您想使用 100 条注释,那么下面的教程将对您有所帮助。

http://www.raywenderlich.com/21365/introduction-to-mapkit-in-ios-6-tutorial

在本教程中,如果您检查以下方法,它将解决您的问题。

(void)plotCrimePositions:(NSData *)responseData {

for (id<MKAnnotation> annotation in _mapView.annotations) {
    [_mapView removeAnnotation:annotation];
}

NSDictionary *root = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:nil];

NSArray *data = [root objectForKey:@"data"];

for (NSArray *row in data) {

    NSNumber * latitude = [[row objectAtIndex:22]objectAtIndex:1];

    NSNumber * longitude = [[row objectAtIndex:22]objectAtIndex:2];

    NSString * crimeDescription = [row objectAtIndex:18];

    NSString * address = [row objectAtIndex:14];

    CLLocationCoordinate2D coordinate;

    coordinate.latitude = latitude.doubleValue;

    coordinate.longitude = longitude.doubleValue;

    MyLocation *annotation = [[MyLocation alloc] initWithName:crimeDescription address:address coordinate:coordinate] ;
    [_mapView addAnnotation:annotation];
}
}

【讨论】:

  • '[_mapView removeAnnotations:_mapview.annotations];'做你的第一个循环所做的事情。
  • 请查看此链接中的蜘蛛侠动画...yourmapper.com/demo/spiderfy.htm
  • 当我使用正常流程时,地图点相互重叠,无法单击特定地图点。所以通过使用 spiderfy 动画,我们可以实现这一点。任何想法。请检查我想使用 Spiderfy Leafleft 动画显示的这个链接...yourmapper.com/demo/spiderfy.htm点击地图点它将展开。
猜你喜欢
  • 2023-04-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多