Πώς μπορώ να ανοίξετε το Google Maps για οδηγίες χρησιμοποιώντας τις συντεταγμένες για το iPhone

ψήφοι
18

Είμαι με τη χρήση UIMapView να εμφανιστεί θέσεις για το iPhone. Θέλω να κάνω μια οδηγιών από την τρέχουσα τοποθεσία στην περιοχή του ενδιαφέροντος, δεν νομίζω ότι είναι δυνατόν χρησιμοποιώντας MapKit του (αλλά αν είναι παρακαλείστε να ενημερώσετε) Γι 'αυτό και θα ανοίξει είτε την εφαρμογή των Χαρτών Google ή το σαφάρι για να εμφανιστεί.

Μπορώ να το κάνετε αυτό, καθορίζοντας τις συντεταγμένες από την (τρέχουσα θέση) να συντονίζει (η τοποθεσία ενδιαφέροντος) Έχω αυτά τα γεωγραφικά μήκη και πλάτη. Ή μήπως εγώ πρέπει να χρησιμοποιούν διευθύνσεις του δρόμου;

Αν έχω να χρησιμοποιούν διευθύνσεις δρόμο, μπορώ να τους πάρει από το γεωγραφικό πλάτος και μήκος.

Δημοσιεύθηκε 10/10/2009 στις 14:58
πηγή χρήστη
Σε άλλες γλώσσες...                            


7 απαντήσεις

ψήφοι
75

Ναι, δεν είναι δυνατή με τη χρήση MapKit. Θα μπορούσατε να δοκιμάσετε να σχηματίσουν ένα αίτημα url χάρτες Google που περιέχει τόσο την τρέχουσα θέση και τον προορισμό σας, που θα ανοίξει στην εφαρμογή χαρτών της Google με τις οδηγίες.

Εδώ είναι ένα παράδειγμα url:

http://maps.google.com/?saddr=34.052222,-118.243611&daddr=37.322778,-122.031944

Εδώ είναι το πώς θα μπορούσατε να εφαρμόσει αυτό στον κώδικά σας:

CLLocationCoordinate2D start = { 34.052222, -118.243611 };
CLLocationCoordinate2D destination = { 37.322778, -122.031944 };    

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

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:googleMapsURLString]];
Απαντήθηκε 12/10/2009 στις 06:37
πηγή χρήστη

ψήφοι
4

Χρησιμοποιήστε το παρακάτω κώδικα για τις δύο χάρτες google και το μήλο στο Swift 3 -

if UIApplication.shared.canOpenURL(URL(string: "comgooglemaps://")!)
        {
            let urlString = "http://maps.google.com/?daddr=\(destinationLocation.latitude),\(destinationLocation.longitude)&directionsmode=driving"

            // use bellow line for specific source location

            //let urlString = "http://maps.google.com/?saddr=\(sourceLocation.latitude),\(sourceLocation.longitude)&daddr=\(destinationLocation.latitude),\(destinationLocation.longitude)&directionsmode=driving"

            UIApplication.shared.openURL(URL(string: urlString)!)
        }
        else
        {
            //let urlString = "http://maps.apple.com/maps?saddr=\(sourceLocation.latitude),\(sourceLocation.longitude)&daddr=\(destinationLocation.latitude),\(destinationLocation.longitude)&dirflg=d"
            let urlString = "http://maps.apple.com/maps?daddr=\(destinationLocation.latitude),\(destinationLocation.longitude)&dirflg=d"

            UIApplication.shared.openURL(URL(string: urlString)!)
        }
Απαντήθηκε 04/01/2017 στις 19:42
πηγή χρήστη

ψήφοι
2

Είναι possible.Use MKMapView πάρει τη θέση συντεταγμένων όπου θα αξιοποιηθεί στο τηλέφωνο και να χρησιμοποιούν τα δύο συντεταγμένες ζητήσει από το KML αρχείο από την υπηρεσία Google στον ιστό, αναλύσει το KML αρχείο (app δείγμα KML θεατή στην ιστοσελίδα του έργου) και την απεικόνιση των διαδρομών .. ..
ευχαριστώ

Απαντήθηκε 29/06/2011 στις 07:23
πηγή χρήστη

ψήφοι
1

Πρώτη χάρτη έλεγχος google έχει εγκατασταθεί στη συσκευή ή όχι

if ([[UIApplication sharedApplication] canOpenURL:
         [NSURL URLWithString:@"comgooglemaps://"]]) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"comgooglemaps://?saddr=23.0321,72.5252&daddr=22.9783,72.6002&zoom=14&views=traffic"]];
    } else {
        NSLog(@"Can't use comgooglemaps://");
    }

Προσθέστε το ερώτημα σχήμα στο .plist

<key>LSApplicationQueriesSchemes</key>
<array>
 <string>comgooglemaps</string>
</array>
Απαντήθηκε 15/06/2017 στις 11:06
πηγή χρήστη

ψήφοι
1

Είναι δυνατόν να δείξουμε διαδρομή στο MapKit: Απλά χρησιμοποιήστε MKPolyline

Παίρνω polyline κορδόνι από googleMapsApi. Μου αναλύσει στον server με php, και να επιστρέψει τελική εγχόρδων polilyne στην εφαρμογή μου.

NSMutableArray *points = [myApp decodePolyline:[route objectForKey:@"polyline"]];

if([points count] == 0)
{
    return;
}

// while we create the route points, we will also be calculating the bounding box of our route
// so we can easily zoom in on it. 
MKMapPoint northEastPoint; 
MKMapPoint southWestPoint; 

// create a c array of points. 
MKMapPoint* pointArr = malloc(sizeof(CLLocationCoordinate2D) * [points count]);

for(int idx = 0; idx < points.count; idx++)
{
    // break the string down even further to latitude and longitude fields. 
    NSString* currentPointString = [points objectAtIndex:idx];
    NSArray* latLonArr = [currentPointString componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@","]];

    CLLocationDegrees latitude  = [[latLonArr objectAtIndex:0] doubleValue];
    CLLocationDegrees longitude = [[latLonArr objectAtIndex:1] doubleValue];

    // create our coordinate and add it to the correct spot in the array 
    CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(latitude, longitude);

    MKMapPoint point = MKMapPointForCoordinate(coordinate);

    if (idx == 0) {
        northEastPoint = point;
        southWestPoint = point;
    }
    else 
    {
        if (point.x > northEastPoint.x) 
            northEastPoint.x = point.x;
        if(point.y > northEastPoint.y)
            northEastPoint.y = point.y;
        if (point.x < southWestPoint.x) 
            southWestPoint.x = point.x;
        if (point.y < southWestPoint.y) 
            southWestPoint.y = point.y;
    }
    pointArr[idx] = point;
    _currentLenght++;
}

// create the polyline based on the array of points. 
self.routeLine = [MKPolyline polylineWithPoints:pointArr count:points.count];

_routeRect = MKMapRectMake(southWestPoint.x, southWestPoint.y, 
                           northEastPoint.x - southWestPoint.x, 
                           northEastPoint.y - southWestPoint.y);

// clear the memory allocated earlier for the points
free(pointArr);

if (nil != self.routeLine) {
        [self.mapView addOverlay:self.routeLine];
}
[self.mapView setVisibleMapRect:_routeRect];

Και δείχνει:

- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
{
MKOverlayView* overlayView = nil;

if(overlay == self.routeLine)
{
    self.routeLineView = [[[MKPolylineView alloc] initWithPolyline:self.routeLine] autorelease];
    self.routeLineView.fillColor = [UIColor blueColor];
    self.routeLineView.strokeColor = TICNavigatorColor;
    self.routeLineView.lineWidth = 7;
    self.routeLineView.lineJoin = kCGLineJoinRound;
    self.routeLineView.lineCap = kCGLineCapRound;

    overlayView = self.routeLineView;
}

return overlayView; 
}

Δοκίμασε το.

Απαντήθηκε 28/09/2012 στις 07:53
πηγή χρήστη

ψήφοι
1

Μια σταθερή λύση είναι να δημιουργήσετε έναν ελεγκτή άποψη με NIB που περιλαμβάνει ένα UIWebView, και στη συνέχεια να περάσει το URL που ασκεί υπηρεσίες χάρτης / κατεύθυνση της Google. Με αυτό τον τρόπο, θα κρατήσει το χρήστη της εφαρμογής. Η προσέγγιση αυτή δεν είναι επαρκής, όταν τραβώντας μια ιστοσελίδα, επειδή το κιτ της Apple δεν υποστηρίζει ζουμ. Αλλά με OS4, τουλάχιστον ο χρήστης να κάνετε διπλό κλικ στο κουμπί σπίτι και να επιστρέψετε στην εφαρμογή.

Απαντήθηκε 07/05/2010 στις 00:55
πηγή χρήστη

ψήφοι
-1

Μπορείτε να επικοινωνήσετε με την πινέζα στον εαυτό σας και όταν ανοίγετε το σύνδεσμο στο email, θα δείξει τις συντεταγμένες.

Απαντήθηκε 18/08/2011 στις 06:54
πηγή χρήστη

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