iOS Google Maps API Route Not Showing Up Correctly -


so if use overview_polyline, works properly. however, not contain points, have opted loop through steps , append paths make large, accurate path. reason, path shows say, chicago los angeles way off, looking this:

http://imgur.com/avamep2

here code:

- (ibaction)showroute {     [otgnetworkrequest fetchroutewithstart:self.startlocation withend:self.endlocation success:^(afhttprequestoperation *operation, id responseobject) {         nsdictionary *json = responseobject;         nsarray *routes = json[@"routes"];         nsstring *encodedoverviewpath = @"";          [self.routes removeallobjects];         self.routes = [[nsmutablearray alloc] init];          (int = 0; < routes.count; i++) {             nsarray *legs = routes[i][@"legs"];             nsmutablearray *steps = [[nsmutablearray alloc] init];             nsinteger distance = 0;             nsinteger traveltime = 0;             (int j = 0; j < legs.count; j++) {                 distance += [legs[j][@"distance"][@"value"] intvalue];                 traveltime += [legs[j][@"duration"][@"value"] intvalue];                 [steps addobjectsfromarray:legs[j][@"steps"]];                 (int l = 0; l < steps.count; l++) {                     encodedoverviewpath = [encodedoverviewpath stringbyappendingstring:steps[l][@"polyline"][@"points"]];                  }             }              nsdictionary *route = @{                                     @"path": [gmspath pathfromencodedpath:encodedoverviewpath],                                     @"distance": [nsnumber numberwithinteger:distance],                                     @"traveltime" : [nsnumber numberwithinteger:traveltime],                                     @"steps" : steps};              [self.routes addobject:route];          }          // now, take first route in list         nsinteger routeindex = 0;         self.routeline.map = nil;         self.routeline = [gmspolyline polylinewithpath:self.routes[routeindex][@"path"]];         self.routeline.strokecolor = [uicolor bluecolor];         self.routeline.strokewidth = 3;         self.routeline.map = self.mapview;          // converting distance , time readable values         nsinteger distance = [self.routes[routeindex][@"distance"] intvalue];         nsinteger traveltime = [self.routes[routeindex][@"traveltime"] intvalue];          self.distance = [self convertmeterstomiles:distance];         self.traveltime = [self convertsecondstohoursminutes:traveltime];         // update yelp search view new distance , time         self.estimateddistanceandtimelabel.text = [nsstring stringwithformat:@"distance: %@, travel time: %@", self.distance, self.traveltime];          gmscoordinatebounds *bounds = [[gmscoordinatebounds alloc] initwithpath:self.routes[routeindex][@"path"]];         [self.mapview animatewithcameraupdate:[gmscameraupdate fitbounds:bounds withpadding:50]];     }]; } 

so seems creating new path appending polyline points doesn't work - had loop through each polyline, extract coordinates of points made up, , add new large mutable path. works then.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -