2
Я дал альтернативу для карт Apple, которые называются картами Google. В этом вопросе и ответе есть решение о том, как создать карту google и создать маркер на карте с описанием.Реализация карт Google для ios
Я дал альтернативу для карт Apple, которые называются картами Google. В этом вопросе и ответе есть решение о том, как создать карту google и создать маркер на карте с описанием.Реализация карт Google для ios
Первый гол шаги, перечисленные в этой ссылке https://developers.google.com/maps/documentation/ios/start
Код для создания карты.
CLLocationCoordinate2D coordinate = [self getLocation];
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:coordinate.latitude
longitude:coordinate.longitude
zoom:15];
mapView = [GMSMapView mapWithFrame:CGRectMake(0, 0, 320, 120) camera:camera];
[mapView animateToCameraPosition:camera];
mapView.delegate = self;
mapView.myLocationEnabled = YES;
[self.view addSubview:mapView];
//getlocation method
-(CLLocationCoordinate2D) getLocation{
CLLocationManager *locationManager = [[[CLLocationManager alloc] init] autorelease];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.distanceFilter = kCLDistanceFilterNone;
[locationManager startUpdatingLocation];
CLLocation *location = [locationManager location];
CLLocationCoordinate2D coordinate = [location coordinate];
return coordinate;
}
Создание маркера текущего местоположения на карте.
[[GMSGeocoder geocoder] reverseGeocodeCoordinate:CLLocationCoordinate2DMake(coordinate.latitude,coordinate.longitude) completionHandler:^(GMSReverseGeocodeResponse *response, NSError *error)
{
NSLog(@"Error is %@", error) ;
NSLog(@"%@" , response.firstResult.addressLine1) ;
NSLog(@"%@" , response.firstResult.addressLine2) ;
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = coordinate;
marker.title = response.firstResult.addressLine1;
marker.snippet = response.firstResult.addressLine2;
marker.appearAnimation = kGMSMarkerAnimationPop;
NSArray* parts = [response.firstResult.addressLine2 componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@","]];
locValueLabel.text = [parts objectAtIndex:0];
marker.map = mapView;
} ] ;