पुन: प्राप्त UserLocation MapKit के साथ समन्वय

वोट
5

मैं अपने आवेदन में MapKit का उपयोग कर रहा हूँ और साथ उपयोगकर्ता स्थान disaply


[mapview setShowUserLocation:YES];

मैं region.center.latitude और userLocation के समन्वय के साथ region.center.longitude सेट करना चाहते हैं, यह कैसे करना है?

01/02/2010 को 11:34
का स्रोत उपयोगकर्ता
अन्य भाषाओं में...                            


5 जवाब

वोट
10

यहाँ मेरी जवाब है, मुझे लगता है कि और उसके काम करने की तरह कुछ प्रयास करें:


//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]; }
10/03/2010 को 11:43
का स्रोत उपयोगकर्ता

वोट
6

बहुत आसान:

-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.location.coordinate, 1500, 1500);
[mapView setRegion:region animated:YES];
}
15/08/2012 को 14:52
का स्रोत उपयोगकर्ता

वोट
2

किसी कारण से, यह मेरे लिए काम नहीं किया। यह मेरे निर्देशांक (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];
20/12/2010 को 09:47
का स्रोत उपयोगकर्ता

वोट
1

: मैं इस अपने सवाल का जवाब लगता है रिटर्निंग MapKit Userlocation निर्देशांक

(का उपयोग करता है mapView.userLocation.location.coordinate.latitudeऔर mapView.userLocation.location.coordinate.longitude properties)

और उसके बाद में उन निर्देशांक इंजेक्षन

-(void)setCenterCoordinate:(CLLocationCoordinate2D)coordinate animated:(BOOL)animated

अपने MKMapView उदाहरण के।

01/02/2010 को 11:41
का स्रोत उपयोगकर्ता

वोट
0

प्रतिनिधि का उपयोग करते हुए:

  1. MapKit प्रतिनिधि जोड़ें: MKMapViewDelegate
  2. पाना विधि: MapView didUpdateUserLocation
    -(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
        MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.location.coordinate,
            500, 500);
        [mapView setRegion:region animated:YES];
    }
    

प्रतिनिधि के बिना:

[self.mapView setuserTrackingMode:MKUserTrackingModeFollow];
23/05/2019 को 04:03
का स्रोत उपयोगकर्ता

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more