sacar para obtener mis mapas google geograficas funciona coordenadas aplicacion iphone google-maps mapkit coordinates

iphone - para - obtener coordenadas google maps



¿Cómo abro Google Maps para obtener indicaciones con las coordenadas en el iPhone? (7)

Es posible mostrar la ruta en MapKit: solo use MKPolyline

Obtengo cadena de polilínea de googleMapsApi. Lo analizo en el servidor con php y devuelvo la cadena polilyne final a mi aplicación.

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

Y mostrando:

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

Darle una oportunidad.

Estoy usando UIMapView para mostrar ubicaciones en el iPhone. Quiero hacer una ruta desde la ubicación actual a la ubicación de interés, no creo que sea posible usar MapKit (pero si es así, infórmelo). Abriré la aplicación Google Maps o el safari para mostrarla.

¿Puedo hacer esto especificando las coordenadas de (ubicación actual) a las coordenadas (la ubicación de interés)? Tengo estas longitudes y latitudes. ¿O tengo que usar direcciones de calles?

Si tengo que usar direcciones de calles, ¿puedo obtenerlas desde la latitud y la longitud?


Es posible. Use MKMapView Obtenga la coordenada de ubicación donde tocó el teléfono y usando las dos coordenadas solicite el archivo KML del servicio web de Google, analice el archivo KML (visor de KML de la aplicación de muestra en el sitio del desarrollador) y muestre las rutas. ..
Gracias


Puede enviar por correo electrónico el pin dejado caer y cuando abra el enlace en el correo electrónico, se mostrarán las coordenadas.


Sí, no es posible usar MapKit. Puede intentar formar una solicitud de URL de Google Maps que contenga su ubicación actual y el destino que se abrirá en la aplicación Google Maps con las instrucciones.

Aquí hay un ejemplo de url:

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

Así es como puedes implementar esto en tu código:

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


Una solución sólida es crear un controlador de vista con un NIB que incluya un UIWebView y luego pasar la URL que ejerce los servicios de mapa / dirección de Google. De esta manera, mantienes al usuario en la aplicación. Este enfoque no es suficiente al abrir una página web, porque el kit de Apple no admite el zoom. Pero con OS4, al menos el usuario puede hacer doble clic en el botón de inicio y volver a la aplicación.


Use el código de abajo para los mapas de Google y Apple en 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)!) }


Primer cheque google map está instalado en el dispositivo o no

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://"); }

Agregar esquema de consulta en .plist

<key>LSApplicationQueriesSchemes</key> <array> <string>comgooglemaps</string> </array>