MapKit-Route-Directions
MapKit-Route-Directions copied to clipboard
Google changed the API a bit, this is a quick fix.
fix in UICGRoute.m to get it working :
// NSArray *allKeys = [dictionaryRepresentation allKeys]; NSDictionary *k = [dictionaryRepresentation objectForKey:@"D"]; NSArray *stepDics = [[dictionaryRepresentation objectForKey:@"D"] objectForKey:@"Steps"];
They changed it again?
i dont know but i had to change these lines to get it to work. couldn't find how to download your fix.. so perhaps i have downloaded the original and fixed the same thing (i'm sorry if that is the case!)
My fix uses the F key instead of D, don't know the significance thou, google maps api's is a bit strange
it's changed again, look for dictionary with steps key
NSString *key = @""; NSDictionary *dd; for (NSString *ky in allKeys) { if([[dictionaryRepresentation objectForKey:ky] class] == [dd class] && [[dictionaryRepresentation objectForKey:ky] objectForKey:@"Steps"]!=nil){ key = [ky copy]; break; } } NSDictionary *k = [dictionaryRepresentation objectForKey:key];
RouteListViewController is not showing anything. It is completely blank. Please anyone help me find it out.
Thanks for the help in advance. Waiting for early reply...
It always display 500 geocode error.
Just found a fix! here it is:
Change the original code in this way:
- Comment these lines //NSArray *allKeys = [dictionaryRepresentation allKeys]; //NSDictionary *k = [dictionaryRepresentation objectForKey:[allKeys objectAtIndex:[allKeys count] - 1]]; //NSArray *stepDics = [k objectForKey:@"Steps"];
- Add this line: //Google has changed the key to "pr" that contains the "Steps" dict NSDictionary *k = [dictionaryRepresentation objectForKey:@"pr"];
- Add this line: NSArray *stepDics = [[dictionaryRepresentation objectForKey:@"pr"] objectForKey:@"Steps"];
That's all there is to it! Enjoy!!!
Cheers! Radorbit India
Hi even after implemented the "radorbit" fix the RouteListViewController is not showing anything. It is completely blank. Please anyone help me find it out.
Has changed API again ? I tryed to fix this code.
UICGRoute#initWithDictionaryRepresentation
//NSArray *allKeys = [dictionaryRepresentation allKeys]; //NSDictionary *k = [dictionaryRepresentation objectForKey:[allKeys objectAtIndex:[allKeys count] - 1]]; //NSArray *stepDics = [k objectForKey:@"Steps"]; NSDictionary *k = [dictionaryRepresentation objectForKey:@"A"]; NSArray *stepDics = [[dictionaryRepresentation objectForKey:@"A"] objectForKey:@"Steps"];
It worked at the moment.
"RouteListViewController is not showing anything. It is completely blank.."
Same thing, any solution?
IF found probably a more reliable solution to that instead of continue to change the key, and probably I will add a more reliable at all. This is a beginning it just loop through the dictionaries looking for the right with the "STep" key. Hope this helps. Of course remove the unnecessary lines.
NSSet * setOfKeys = [dictionaryRepresentation keysOfEntriesPassingTest:^(id key, id obj, BOOL * stop){ if ([obj isKindOfClass:[NSDictionary class]]) { for (NSString *keyString in [obj allKeys]) { if ([keyString isEqualToString:@"Steps"]) { *stop=YES; return YES; } } } return NO; }]; NSDictionary * k = [dictionaryRepresentation objectForKey:[setOfKeys anyObject]]; NSArray * stepDics = [k objectForKey:@"Steps"];
Bye, Andrea
Thanks a lot Andrea! You saved my neck..
I have just a question, I'm getting a lot of Japanese characters, is possible to get rid off them or translate them??
EDIT: I Got it.. chaged the Locale Identifier
Thanks!
Hi afrade, I do not remember quite well it's been a long time. You can find the ideogram in the RootViewController if I remember well, they are just placeholders for addresses, take a look around TableView datasource and delegate methods. Pay attention about two things:
- (void)webView:(UIWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame; is undocumented, I do not know if apple will accept it
- (void)setContentToHTMLString:(id)fp8; is private API you cannot use it
- recently google returns some html codification in the json that the SBJSON lib is unable to parse, you should see an error, try with different address to see it.
I've managed last two, removing all html encoding inside the string-->parsing as written-->show plain text, instead of converting from html using private API. The first is different and little bit complicated because you should modify the javascript part and some delegates around. Ciao
I am sorry but i am very new to Xcode, I love this code but I cannot find a way to pass current latitude and longitude as start address, can someone please help?
Guys is this legal with new Ios6? And Google preventing to publish its routes other than Google Maps?
Google has again changed the key to "g"
Replace NSArray *stepDics; NSDictionary *k; for (int i = 0; i<allKeys.count; i++) { k = [dictionaryRepresentation objectForKey:[allKeys objectAtIndex:i]]; if ([k objectForKey:@"Steps"]) { stepDics = [k objectForKey:@"Steps"]; break; } }
with NSDictionary *k = [dictionaryRepresentation objectForKey:[allKeys objectAtIndex:[allKeys count] - 1]]; NSArray *stepDics = [k objectForKey:@"Steps"];
now if google change the response key it will work :)
Thanks a lot Andrea!.........
Great effort ....