0

I need to create path exactly according to road coordinates from google map api.I am partially successful with the help of this "http://maps.googleapis.com/maps/api/directions/json?&origin=%@,%@&destination=%@,%@&sensor=false" service.

But this service provide me the coordinates as show in this image .Map without zooming

When we zoom this path it looks like this image .Map with zoom

Actually, I want to get exactly road coordinates with every curve.

Firstly I did this task with the javascript file which was in one of the tutorial of google map (SBMapwithRoute)but don't know why that javascript file stop responding now. If any body know how this task will perform than please help me.Thank you

user786
  • 1
  • 8
  • check this topic http://stackoverflow.com/questions/9217274/how-to-decode-the-google-directions-api-polylines-field-into-lat-long-points-in – user2377971 Dec 13 '13 at 09:46
  • @user2377971 thanks for your quick comment, but I am using google map api and the link you suggest is according to MKmapkit. – user786 Dec 13 '13 at 09:57

1 Answers1

0

I have posted one artical on my blog may be help full check it

http://www.jogendra.com/wayPath

May be hellfull for you

if you wants get waypoints from your google maps waypath. then use this

 NSMutableArray *wayPointsArray =  [self decodePolyLine:polyline.path.encodedPath];
  • here decodePolyline is function that you seen on my blog
  • polyline is object of GMSPolyline *_polyline;

Thnaks

Community
  • 1
  • 1
Jogendra.Com
  • 6,394
  • 2
  • 28
  • 35
  • thanks for your answer.I got the coordinates,But when i am creating polyline by adding this code with your code it got crash. I can't understand the problem. – user786 Dec 13 '13 at 12:57
  • I am using this code with your code.Thanks once again GMSMutablePath *pointsArray = [GMSMutablePath path]; for (int x =0;x<[array count]; x++) { CLLocation *lcord=[array objectAtIndex:x]; [pointsArray addCoordinate:CLLocationCoordinate2DMake(lcord.coordinate.latitude,lcord.coordinate.longitude)]; } GMSPolyline *polyline = [GMSPolyline polylineWithPath:pointsArray]; polyline.strokeColor = [UIColor greenColor]; polyline.strokeWidth = 5.f; polyline.geodesic = YES; polyline.map = mapView_; – user786 Dec 13 '13 at 12:58
  • The error is-> void SendDelegateMessage(NSInvocation *): delegate (webView:identifierForInitialRequest:fromDataSource:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode – user786 Dec 13 '13 at 13:31
  • Are you using Google Map ya Apple Map ? – Jogendra.Com Dec 13 '13 at 14:01
  • Both map's working are differents . Please explain fully. I'll try to my best. – Jogendra.Com Dec 13 '13 at 14:07
  • and thank you for your help .Please tell me which type of explanation do you need. – user786 Dec 13 '13 at 14:48
  • Are you want draw path with google map ios sdk ? Am I Right ya wrong. – Jogendra.Com Dec 14 '13 at 05:35
  • If you are using google map then [Google Map Starting](https://developers.google.com/maps/documentation/ios/start) and after than you wants make path then open this [Google Map Path](https://developers.google.com/maps/documentation/ios/reference/interface_g_m_s_mutable_path) – Jogendra.Com Dec 16 '13 at 13:31
  • thanks for your attention but please read my question carefully.I have to get road coordinates with every curve and have to pass to GMSPolyline of google map api to create overlay. – user786 Dec 16 '13 at 14:38
  • if you're using Google Map, you don't need any waypoint bacause google map already take waypoint – Jogendra.Com Dec 16 '13 at 14:40
  • Actually the thing you was talking about as in this link https://developers.google.com/maps/documentation/directions/?csw=1. But there is no any service which provide me the exact coordinates of the road with every curve. – user786 Dec 17 '13 at 07:43
  • Thanks once again @Joge for your help.But when i am using waypoint services than there is no any need for encoding simply the waypoint service return the data and the method you refered on your link is just to return an array of coordinates which i had mentioned first comment.That I got the coordinates,But when i am creating polyline it got crash. – user786 Dec 17 '13 at 09:33
  • I will send you a demo project of this, But you need some wait for this. – Jogendra.Com Dec 17 '13 at 10:48
  • Thanks once again @joge and I will wait for your demo. – user786 Dec 17 '13 at 11:58