मैं अपने आवेदन में MapKit का उपयोग कर रहा हूँ और साथ उपयोगकर्ता स्थान disaply
[mapview setShowUserLocation:YES];
मैं region.center.latitude और userLocation के समन्वय के साथ region.center.longitude सेट करना चाहते हैं, यह कैसे करना है?
मैं अपने आवेदन में MapKit का उपयोग कर रहा हूँ और साथ उपयोगकर्ता स्थान disaply
[mapview setShowUserLocation:YES];
मैं region.center.latitude और userLocation के समन्वय के साथ region.center.longitude सेट करना चाहते हैं, यह कैसे करना है?
यहाँ मेरी जवाब है, मुझे लगता है कि और उसके काम करने की तरह कुछ प्रयास करें:
//inside my ViewDidLOad
locManager = [[CLLocationManager alloc] init];
[locManager setDelegate:self];
[locManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locManager startUpdatingLocation];
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
CLLocationCoordinate2D loc = [newLocation coordinate];
[maptView setCenterCoordiante:loc];
}
बहुत आसान:
-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.location.coordinate, 1500, 1500);
[mapView setRegion:region animated:YES];
}
किसी कारण से, यह मेरे लिए काम नहीं किया। यह मेरे निर्देशांक (0.0000, 0.0000) के लिए ले रहा है। यदि आप इसे बाहर की जाँच करने का मौका दिया नीचे मेरी कोड है। सहायता के लिए धन्यवाद!
[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
mapView.showsUserLocation=TRUE;
MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
CLLocationCoordinate2D myCoord = {mapView.userLocation.location.coordinate.latitude,mapView.userLocation.location.coordinate.longitude};
[mapView setCenterCoordinate:myCoord animated:YES];
region.span.longitudeDelta = 0.01f;
region.span.latitudeDelta = 0.01f;
[mapView setRegion:region animated:YES];
[mapView setDelegate:self];
: मैं इस अपने सवाल का जवाब लगता है रिटर्निंग MapKit Userlocation निर्देशांक
(का उपयोग करता है mapView.userLocation.location.coordinate.latitudeऔर mapView.userLocation.location.coordinate.longitude properties)
और उसके बाद में उन निर्देशांक इंजेक्षन
-(void)setCenterCoordinate:(CLLocationCoordinate2D)coordinate animated:(BOOL)animated
अपने MKMapView उदाहरण के।
प्रतिनिधि का उपयोग करते हुए:
-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation { MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.location.coordinate, 500, 500); [mapView setRegion:region animated:YES]; }
प्रतिनिधि के बिना:
[self.mapView setuserTrackingMode:MKUserTrackingModeFollow];