显示spiderfy leaflet注解MKMapView [英] Display spiderfy leaflet annotation MKMapView

查看:138
本文介绍了显示spiderfy leaflet注解MKMapView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

链接。



我想在iphone中使用同样的东西。 如果你想要使用100的注释然后下面是教程,这将有助于你。



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



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

  (void)plotCrimePositions:(NSData *)responseData {

(_mapView.annotations中的id< MKAnnotation>注解){
[_mapView removeAnnotation:annotation];
}

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

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

(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.latitude = latitude.doubleValue;

coordinate.longitude = longitude.doubleValue;

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


I want to show 100 map points using MKMapView on same lat longs. Please see the link.

Same thing i want in iphone.

解决方案

If you want to use 100's of annotation then below is the tutorial which will help you.

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

In this tutorial if you check the below method it will resolve your issue.

(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];
}
}

这篇关于显示spiderfy leaflet注解MKMapView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆