i iphone koordinatlarını kullanarak yön için Google Maps uygulamasını açmak nasıl

oy
18

Ben iPhone'da yerleri görüntülemek için UIMapView kullanıyorum. Ben ilgi konuma bulunduğunuz konumdan bir yön yapmak istiyorum, ben olası kullanarak MapKit düşünüyorum (ama eğer haber veriniz) Ben görüntülemek için Google Maps uygulamasını veya safari ya açılacaktır yoktur.

i (ilgilenilen yeri) Ben bu enlem ve boylam bilgisi koordinatlarına (mevcut konum) den koordinatlarını belirleyerek bunu yapabilir. Ya ben sokak adresleri kullanmak gerekiyor?

Ben sokak adreslerini kullanmak zorunda yoksa, ben onları enlem ve boylam alabilirsiniz.

Oluştur 10/10/2009 saat 14:58
kaynak kullanıcı
Diğer dillerde...                            


7 cevaplar

oy
75

Evet, MapKit kullanılarak mümkün değildir. Tarifleriyle birlikte Google Haritalar uygulamasında açar anki konumunuzu ve hedef noktalarını içeren bir Google haritaları url isteği oluşturmak için deneyebilirsiniz.

İşte bir örnek url var:

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

Burada kodunuzda bunu uygulamak açıklanmıştır:

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]];
Cevap 12/10/2009 saat 06:37
kaynak kullanıcı

oy
4

Swift 3'te hem google ve elma haritaları için feryat kodu kullanın -

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)!)
        }
Cevap 04/01/2017 saat 19:42
kaynak kullanıcı

oy
2

Bu possible.Use olan MKMapView telefonda vurdu ve kullanmanın iki koordinatlar talep konum koordinat alın KML , google web hizmetinden dosyayı ayrıştırmak KML (geliştirici sitesinde örnek uygulaması KML izleyici) dosyası ve rotaları görüntülemek .. ..
teşekkürler

Cevap 29/06/2011 saat 07:23
kaynak kullanıcı

oy
1

İlk onay google haritası cihazında veya yüklü

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 sorgu şema ekle

<key>LSApplicationQueriesSchemes</key>
<array>
 <string>comgooglemaps</string>
</array>
Cevap 15/06/2017 saat 11:06
kaynak kullanıcı

oy
1

Sadece MKPolyline kullanın: MapKit rotayı göstermek mümkündür

Ben googleMapsApi dan Çoklu çizgi dize olsun. Ben php ile sunucuda ayrıştırın ve Uygulamama son polilyne dize döndürür.

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];

Ve gösterilen:

- (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; 
}

Bir şans ver.

Cevap 28/09/2012 saat 07:53
kaynak kullanıcı

oy
1

Sağlam bir çözüm UIWebView içeren bir ELVES ile bir görünüm denetleyicisi oluşturmak ve sonra Google'ın harita / yön hizmeti yerine getirmektedir URL'yi geçmektir. Bu şekilde, uygulamada kullanıcıya tutun. Bir web sayfasını yukarı çekerek ne zaman Apple kiti yakınlaştırma desteklemediği için bu yaklaşım değildir yeterlidir. Ama OS4 ile, en azından kullanıcı ana düğmesini tıklayıp tekrar uygulamasına geçiş çift.

Cevap 07/05/2010 saat 00:55
kaynak kullanıcı

oy
-1

Kendine düştü pimi e-posta ve e-postadaki bağlantıyı açtığınızda, bu koordinatları gösterecektir.

Cevap 18/08/2011 saat 06:54
kaynak kullanıcı

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