【问题标题】:Parse MapView pin解析 MapView 引脚
【发布时间】:2015-11-13 09:35:42
【问题描述】:

在我的应用程序中,我有一张地图,可以通过 Parse 直接查看整个城市。现在我会使用不同的图像来识别它们。这些图像加载到我的数据库 Parse 上。我怎样才能看到这些图像?感谢所有我希望我很清楚。这是我的代码:

- (void)viewDidLoad {
[super viewDidLoad];



PFQuery *query = [PFQuery queryWithClassName:@"Citta"];

[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {

    if (!error)
    {

        NSLog(@"QUERY -----> :%@", objects);


        for(NSMutableDictionary *note1 in objects) {
            float realLatitude1 = [[note1 objectForKey:@"Lat"] doubleValue];
            float realLongitude1 = [[note1 objectForKey:@"Lon"] doubleValue];

            NSLog(@"(PARSE) Lat: %f", realLatitude1);
            NSLog(@"(PARSE) Lon: %f", realLongitude1);


            MKPointAnnotation *displayMap = [[MKPointAnnotation alloc] init];

            CLLocationCoordinate2D theCoordinate;
            theCoordinate.latitude = realLatitude1;
            theCoordinate.longitude = realLongitude1;
            displayMap.coordinate = theCoordinate;
            displayMap.title = [note1 objectForKey:@"Nome_citta"];
            displayMap.subtitle = [note1 objectForKey:@"Nome_regione"];
            //displayMap.icon = [note1 objectForKey:@"icona"];
            [self.mapView setDelegate:self];
            [self.mapView addAnnotation:displayMap];


        }
    }

}];

}

- (MKAnnotationView *)mapView:(MKMapView *)mapView
        viewForAnnotation:(id <MKAnnotation>)annotation

{ 静态 NSString *falesieIdentifier = @"falesie"; MKAnnotationView *annotationView = [self.mapView dequeueReusableAnnotationViewWithIdentifier:falesieIdentifier]; if (annotationView == nil) { annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation 重用标识符:falesieIdentifier];

    annotationView.image = [UIImage imageNamed:@"marker.png"];

    annotationView.canShowCallout = YES;




   // UIButton *detailButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

    UIImageView *carView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"UITableNext"]];

    UIButton *blueView = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 50, 44+30)];
    blueView.backgroundColor = UIColorFromRGB(0xffffff);
    [blueView addTarget:self action:@selector(prepareForSegue:sender:) forControlEvents:UIControlEventTouchUpInside];
    carView.frame = CGRectMake(23, 19, carView.image.size.width, carView.image.size.height);
    [blueView addSubview:carView];

    annotationView.rightCalloutAccessoryView = blueView;
        }



        return annotationView;
    }

【问题讨论】:

  • 图像存储在 PFFiles 中?你没有解释你的代码做错了什么......
  • 是的,图像存储在 PFFiles 中,我想知道如何在地图上加载 PFFile

标签: parse-platform mapkit mkannotationview


【解决方案1】:

您可能应该提前下载所有 PFFile,这样当您创建地图注释时,您可以将 annotationView.image 行替换为从下载的文件数据中加载图像,而不是按名称从静态图像中加载。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多