कैसे MapKit में उपयोगकर्ता स्थान प्रदर्शित करने के लिए?

वोट
3

मैं एक उपयोगकर्ता के स्थान के लिए नीले रंग स्पंदन डॉट प्रदर्शित करना चाहते हैं। मैं यह कर रही हूँ:

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation    *)newLocation fromLocation:(CLLocation *)oldLocation{
//some other stuff here
[self.mapView setShowsUserLocation:YES];
}

लेकिन मैं अंत में मिलता है

-[MKUserLocation establishment]: unrecognized selector sent to instance 0x125e90

मैं इस किसी अन्य तरीके से कर रही किया जाना चाहिए?

- संपादित करें -

मैं भी इस कर रहा हूँ, जो है जहाँ मैं अंततः उपरोक्त अपवाद है:

- (MKAnnotationView *) mapView:(MKMapView *)_mapView viewForAnnotation:(AddressNote *) annotation{

if(annotation.establishment != nil){
//do something}

स्थापना मैं AddressNote पर एक कस्टम वर्ग है। स्थापना एक मान होता है तो अपवाद तब होता है। मैं ShowsUserLocation निर्धारित नहीं करते हैं, सब कुछ ठीक काम करता है लेकिन निश्चित रूप से, मैं उपयोगकर्ता स्थान नहीं दिख रहा।

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


3 जवाब

वोट
15

जब viewForAnnotationअनुरोध किया जाता है, तो आप मौसम या नहीं दिया एनोटेशन वर्तमान उपयोगकर्ता स्थान से मेल खाती है की जाँच की जरूरत है। यदि हाँ, तो वापसी नहीं के बराबर है, अन्यथा अपने स्वयं के सामान्य annoationView लौट आते हैं।

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation {
    if (annotation==self.mapView.userLocation)
        return nil;
    //then the rest of your code for all your 'classic' annotations.

[संपादित करें] एक वैकल्पिक तरीका एनोटेशन के वर्ग की तरह जांच करने के लिए है:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation {
    if ([annotation isKindOfClass:[MKUserLocation class]])
        return nil;
    //then the rest of your code for all your 'classic' annotations.

16/03/2010 को 10:05
का स्रोत उपयोगकर्ता

वोट
8

सुनिश्चित नहीं हैं कि वास्तविक समस्या है, लेकिन आप हर अद्यतन पर ऐसा करने की जरूरत नहीं है। एक बार बनाने के बाद इसे सेट करें mapView, और आप व्यापार में होना चाहिए।

mapView.showsUserLocation = YES;

तुम्हें पता है, क्षेत्र में, जहां उपयोगकर्ता वास्तव में है के लिए मानचित्र ज़ूम करने के लिए आवश्यकता हो सकती है डॉट दिखाई दे सकता है के लिए।

14/03/2010 को 20:07
का स्रोत उपयोगकर्ता

वोट
0

तुम गलत प्रतिनिधि विधि का उपयोग कर रहे हैं। MapView के लिए, आप उपयोगकर्ता स्थान को पकड़ने के लिए इस प्रतिनिधि विधि का उपयोग करना चाहिए:

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
}
05/05/2011 को 00:49
का स्रोत उपयोगकर्ता

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