Как установить маркер в положении крана GMSPolygon? - PullRequest
0 голосов
/ 17 октября 2019

Я реализовал GMSPolygon в GMSmapView.

#pragma mark - GMSMapViewDelegate
-(void)mapView:(GMSMapView *)mapView didTapOverlay:(GMSOverlay *)overlay{
    if([overlay isKindOfClass:[GMSPolygon class]]){
        [self removeTapMarker];

        GMSPolygon *polygon = (GMSPolygon *)overlay;
        NSString * title = polygon.title;


        NSPredicate * predicate = [NSPredicate predicateWithFormat:@"region_name == %@", title];
        NSArray * array_region = [array_AllRegions filteredArrayUsingPredicate:predicate];
        if(array_region.count > 0) {
            NSDictionary * dict_region = (NSDictionary *) [array_region objectAtIndex:0];
            if(dict_region.count > 0) {
                RegionPoint * obj_region_point = [[RegionPoint alloc] initWithData:dict_region];

                GMSMarker * marker  = [GMSMarker markerWithPosition:CLLocationCoordinate2DMake(obj_region_point.latitude.doubleValue, obj_region_point.longitude.doubleValue)];
                marker.title = title;
                marker.snippet = [NSString stringWithFormat:@"Area: %@\nPopulation: %@",obj_region_point.region_area,obj_region_point.population];

                marker.icon = [UIImage imageNamed:@"icon_select"];
                marker.map  = self.mapView;
                self.mapView.selectedMarker = marker;

                [array_markers_OnPOlygon addObject:marker];

                [self performSelector:@selector(removeTapMarker) withObject:nil afterDelay:5.0];
            }
        }
    }
}

Здесь я установил маркер в одном из местоположений GMSPath, но мне нужно установить маркер в центре выбранного GMSPolygon.

Пожалуйста, помогите мне.

...