कैसे मैं iphone पर निर्देशांकों का उपयोग दिशाओं के लिए गूगल मैप्स खोलूं

वोट
18

मैं iPhone पर स्थानों को प्रदर्शित करने UIMapView उपयोग कर रहा हूँ। मैं ब्याज के स्थान पर वर्तमान स्थान से एक दिशाओं करना चाहते हैं, मुझे नहीं लगता कि यह संभव है MapKit का उपयोग कर (लेकिन सूचित करें अगर यह होता है) तो मैं या तो गूगल मैप्स आवेदन या सफारी यह प्रदर्शित करने के लिए खुल जाएगा।

मैं (वर्तमान स्थान) से समन्वय को निर्दिष्ट सह तालमेल करने के लिए (रुचि का स्थान) मैं इन देशांतर और अक्षांश है ऐसा कर सकते हैं। या मैं सड़क के पते का उपयोग करना है?

मैं सड़क के पते का उपयोग करना पड़ रहा है, तो मैं उन्हें अक्षांश और देशांतर से प्राप्त कर सकते हैं।

10/10/2009 को 14:58
का स्रोत उपयोगकर्ता
अन्य भाषाओं में...                            


7 जवाब

वोट
75

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

यहाँ एक उदाहरण यूआरएल है:

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

स्विफ्ट 3 में दोनों गूगल और एप्पल नक्शे के लिए bellow कोड का प्रयोग करें -

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 जहां फोन पर उपयोग किया और का उपयोग कर स्थान समन्वय जाओ दो निर्देशांक का अनुरोध एम एल , गूगल वेब सेवा से फ़ाइल को पार्स एम एल फ़ाइल (डेवलपर साइट में नमूना एप्लिकेशन के एम एल दर्शक) और मार्गों प्रदर्शित .. ..
धन्यवाद

29/06/2011 को 07:23
का स्रोत उपयोगकर्ता

वोट
1

पहले जांच कर लें गूगल मानचित्र डिवाइस में है या नहीं स्थापित किया गया है

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

बस MKPolyline का उपयोग: यह MapKit में मार्ग दिखाने के लिए संभव है

मैं googleMapsApi से पॉलीलाइन स्ट्रिंग मिलता है। मैं 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

एक ठोस समाधान एक निब है कि एक UIWebView शामिल साथ एक दृश्य नियंत्रक बनाने के लिए, और फिर यूआरएल कि गूगल के नक्शे / दिशा सेवाओं अभ्यास पार जाते हैं। इस तरह, आप आवेदन में उपयोगकर्ता रखने के लिए। यह दृष्टिकोण क्योंकि एप्पल किट ज़ूम का समर्थन नहीं करता है, जब एक वेब पेज खींच रहा पर्याप्त नहीं है। लेकिन OS4 साथ, कम से कम उपयोगकर्ता घर बटन क्लिक करें और वापस ऐप्लिकेशन पर स्विच दोगुना कर सकते हैं।

07/05/2010 को 00:55
का स्रोत उपयोगकर्ता

वोट
-1

आप अपने आप को करने के लिए नीचे पिन को ईमेल कर सकते हैं और जब आप ईमेल में लिंक खोलते हैं, तो निर्देशांक दिखाएगा।

18/08/2011 को 06:54
का स्रोत उपयोगकर्ता

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