ios - iphone google geocoding request failed -
i want use google geo coding find list of place's latitude longitude name, have no experience of using in iphone, in android call url. when try same in iphone give me error "request denied". guide me how integrate in iphone or should use library bsforwardgeocoder, doing
nsstring *url = [nsstring stringwithformat:@"http://maps.googleapis.com/maps/api/geocode/json?address=%@&sensor=true", locationstring]; url = [url stringbyreplacingoccurrencesofstring:@" " withstring:@"%20"]; nsurl *wurl = [nsurl urlwithstring:url]; nsdictionary *dict = [json objectwithurl:wurl]; nslog(@"%@", dict); and prints
{ results = ( ); status = "request_denied"; }
check this
nsstring *locationstring = @"1600 amphitheatre parkway, mountain view, ca"; nsstring *url = [nsstring stringwithformat:@"http://maps.googleapis.com/maps/api/geocode/json?address=%@&sensor=true", locationstring]; url = [url stringbyreplacingoccurrencesofstring:@" " withstring:@"%20"]; nsurl *wurl = [nsurl urlwithstring:url]; nsdata *data = [nsdata datawithcontentsofurl: wurl]; // fail data server if (nil == data) { nslog(@"error: fail data"); } else{ // parse json data nserror *error; nsdictionary *json = [nsjsonserialization jsonobjectwithdata:data options:kniloptions error:&error]; // check status of result nsstring *resultstatus = [json valueforkey:@"status"]; // if responce valid if ( (nil == error) && [resultstatus isequaltostring:@"ok"] ) { nslog(@"%@", json); } }
reference: the google geocoding api
Comments
Post a Comment