Bekommen Wegbeschreibung Nicht Verfügbar" aufrufen der Google-Maps-mit URLWithString

Habe ich eine app, nutzt Apple Maps, die Recht erfolgreich: ich habe eine Liste mit einigen Punkten des Interesses, und wenn ich Tippen Sie auf eine der ersten die Anwendung zeigt es auf der Karte dann, wenn ich darauf Tippen, es öffnet sich Apple-Maps-Anwendung zu navigieren.

Das problem ist, dass beim ersten Tippen Sie auf/start der Apple-Maps-app wird geöffnet, aber weder wenn es Sie fragt, die Erlaubnis zur Verwendung von Benutzer-Standort, oder wenn es nicht funktioniert, ist Apple Maps funktioniert nicht und gibt zurück : "Richtungen Nicht Verfügbar. Richtung konnte nicht gefunden werden zwischen diesen Standort.", aber in der Allgemeinen Einstellung der Ortungsdienst für die app ist eingestellt.

Ich dachte, ich hatte eine Art timeout, weil meine app dauert zu lange zu analysieren-Daten für die navigation (ich abrufen von Daten aus einer xml -) aber auf das zweite Tippen funktioniert alles einwandfrei, auch wenn ich es aus dem Mac im debugging-Modus (und es parst xml-sogar das zweite mal)...

Ich hoffe, dass ich gut erklärt. Irgendwelche Tipps?

   -(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation 
{
    MKPinAnnotationView *pinView = nil; 
    if(annotation != mapView.userLocation) 
    {
    static NSString *defaultPinID = @"com.invasivecode.pin";
    pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
    if ( pinView == nil ) pinView = [[[MKPinAnnotationView alloc]
                                      initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];

    pinView.pinColor = MKPinAnnotationColorRed; 


    UIButton *myAccessoryButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 24, 24)];
    [myAccessoryButton setBackgroundColor:[UIColor clearColor]];
    [myAccessoryButton setImage:[UIImage imageNamed:@"flag.png"] forState:UIControlStateNormal];
    pinView.rightCalloutAccessoryView = myAccessoryButton;
    pinView.canShowCallout = YES;
    pinView.animatesDrop = YES;
    [myAccessoryButton release];
} 
else {
    [mapView.userLocation setTitle:@"You're here"];
}
return pinView;
}

-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control{

locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self; 
locationManager.desiredAccuracy = kCLLocationAccuracyBest; 
locationManager.distanceFilter = kCLDistanceFilterNone; 
[locationManager startUpdatingLocation];

CLLocation *location = [locationManager location];

//Configure the new event with information from the location
CLLocationCoordinate2D coordinate = [location coordinate];

NSString *latitude = [NSString stringWithFormat:@"%f", coordinate.latitude]; 
NSString *longitude = [NSString stringWithFormat:@"%f", coordinate.longitude];


CLLocationCoordinate2D start = { [latitude floatValue], [longitude floatValue] };
CLLocationCoordinate2D end = {[posto.latitude floatValue], [posto.longitude floatValue]};

NSString *googleMapsURLString = [NSString stringWithFormat:@"http://maps.google.com/?saddr=%1.6f,%1.6f&daddr=%1.6f,%1.6f", start.latitude, start.longitude, end.latitude, end.longitude];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:googleMapsURLString]];
}

InformationsquelleAutor Miwi | 2012-03-26

Schreibe einen Kommentar