Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google changed the API a bit, this is a quick fix. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ptxmac
Copy link

@ptxmac ptxmac commented Nov 1, 2010

No description provided.

@ghost
Copy link

ghost commented May 31, 2011

fix in UICGRoute.m to get it working :

// NSArray *allKeys = [dictionaryRepresentation allKeys];
NSDictionary *k = [dictionaryRepresentation objectForKey:@"D"];
NSArray *stepDics = [[dictionaryRepresentation objectForKey:@"D"] objectForKey:@"Steps"];

@ptxmac
Copy link
Author

ptxmac commented May 31, 2011

They changed it again?

@ghost
Copy link

ghost commented May 31, 2011

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!)

@ptxmac
Copy link
Author

ptxmac commented May 31, 2011

My fix uses the F key instead of D, don't know the significance thou, google maps api's is a bit strange

@hasnat
Copy link

hasnat commented Jul 11, 2011

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

@maksumon
Copy link

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...

@shipat8585
Copy link

It always display 500 geocode error.

@radorbit
Copy link

radorbit commented Oct 6, 2011

Just found a fix! here it is:

Change the original code in this way:

  1. Comment these lines
    //NSArray *allKeys = [dictionaryRepresentation allKeys];
    //NSDictionary *k = [dictionaryRepresentation objectForKey:[allKeys objectAtIndex:[allKeys count] - 1]];
    //NSArray *stepDics = [k objectForKey:@"Steps"];
  2. Add this line:
    //Google has changed the key to "pr" that contains the "Steps" dict
    NSDictionary *k = [dictionaryRepresentation objectForKey:@"pr"];
  3. Add this line:
    NSArray *stepDics = [[dictionaryRepresentation objectForKey:@"pr"] objectForKey:@"Steps"];

That's all there is to it! Enjoy!!!

Cheers!
Radorbit India

@maksumon
Copy link

maksumon commented Oct 9, 2011

Hi even after implemented the "radorbit" fix the RouteListViewController is not showing anything. It is completely blank. Please anyone help me find it out.

@hmori
Copy link

hmori commented Oct 13, 2011

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.

@steve21124
Copy link

"RouteListViewController is not showing anything. It is completely blank.."

Same thing, any solution?

@DrAma999
Copy link

DrAma999 commented Feb 7, 2012

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

@afrade
Copy link

afrade commented May 10, 2012

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!

@DrAma999
Copy link

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

@xcodecs
Copy link

xcodecs commented Sep 14, 2012

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?

@zelin
Copy link

zelin commented Dec 28, 2012

Guys is this legal with new Ios6? And Google preventing to publish its routes other than Google Maps?

@SurenderRathore
Copy link

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 :)

@NAGAVENDRA
Copy link

Thanks a lot Andrea!.........

Great effort ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.