I'm having a few issues with MKMapView! I'm new to the mapping! What i'm trying to do:
Mapview loads up and drops a placemarker on user's current location, and on the address of the selected customer. This code drops a placemarker on the address of the selected customer fine, but i can't seem to get it to drop one on the user's current location!
Any ideas why?
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder geocodeAddressString:postcodeForMap
completionHandler:^(NSArray* placemarks, NSError* error){
NSLog(@"Co-ordinate geocode is %@", [placemarks objectAtIndex:0]);
for (CLPlacemark* aPlacemark in placemarks)
{
CLPlacemark *topResult = [placemarks objectAtIndex:0];
MKPlacemark *placemark = [[MKPlacemark alloc] initWithPlacemark:topResult];
MKPlacemark *mPlacemark = [[MKPlacemark alloc] initWithCoordinate:mapView.userLocation.location.coordinate addressDictionary:nil];
MKCoordinateRegion region = mapView.region;
region.center = placemark.region.center;
region.span.longitudeDelta /= 8.0;
region.span.latitudeDelta /= 8.0;
[mapView setRegion:region animated:YES];
[mapView addAnnotation:placemark];
[mapView addAnnotation:mPlacemark];
}
}
];
You can get user location using the following code
When you tell the location manager to get the locations if
Allowed
thelocationmanager
calls its delegate method see below