Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6356085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:53:44+00:00 2026-05-24T22:53:44+00:00

I have use Google direction API for calculating latitude and longitude when user given

  • 0

I have use Google direction API for calculating latitude and longitude when user given origin and destination address. In this API I also get latitude and longitude of number of mid points. I have all stored in array. Now I want to add value of latitude and longitude of each point in new array. How store value of them in an array? When get data from XML parsing then I use this code:

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{
    if (qName)
    {
        elementName = qName;
    }
        
    else if ([elementName isEqualToString:@"start_location"])
    {
        isFoundStartLoc = NO;
    }           
    else if ([elementName isEqualToString:@"end_location"])
    {
        isFoundEndLoc = NO;
    }               
    else if ([elementName isEqualToString:@"lat"])
    {
        if (isFoundStep)
        {
            if (isFoundStartLoc)
            {
                stepObject.startLocLat = [self.currentElement doubleValue];
            }
            else if(isFoundEndLoc)
            {
                stepObject.endLocLat = [self.currentElement doubleValue];
            }
        }
        else{
            if (isFoundStartLoc)
            {
                slegObject.startLocLat = [self.currentElement doubleValue];
            }
            else if(isFoundEndLoc)
            {
                slegObject.endLocLat = [self.currentElement doubleValue];
            }
        }
    }           
    else if ([elementName isEqualToString:@"lng"])
    {
        if (isFoundStep) 
        {
            if (isFoundStartLoc)
            {
                stepObject.startLocLong = [self.currentElement doubleValue];
            }
            else if(isFoundEndLoc)
            {
                stepObject.endLocLong = [self.currentElement doubleValue];
            }
        }
        else{
            if (isFoundStartLoc)
        {
            slegObject.startLocLong = [self.currentElement doubleValue];
        }
        else if(isFoundEndLoc)
        {
            slegObject.endLocLong = [self.currentElement doubleValue];
        }
            }
    }               
    else if ([elementName isEqualToString:@"distance"])
    {
        isFoundDistance = NO;
    }   
    else if ([elementName isEqualToString:@"text"])
    {
        if (isFoundStep)
        {
            if (isFoundDistance){
                    stepObject.distance=[self.currentElement doubleValue];
                }
        }
        else
        {
            if(isFoundDistance)
            {
                slegObject.total_distance=[self.currentElement doubleValue];
            }
        }
    }
    else if ([elementName isEqualToString:@"step"])
    {
        if (ListofSteps1==nil)
        {
            ListofSteps1=[[NSMutableArray alloc]init];
        }
        [ListofSteps1 addObject:stepObject];
        [stepObject release];
        stepObject=nil;
        isFoundStep=NO;
    }
    
    else if ([elementName isEqualToString:@"leg"])
    {
        if (listofPoint==nil)
        {
            listofPoint=[[NSMutableArray alloc]init];
        }
        [listofPoint addObject:slegObject];
        [slegObject release];
        slegObject=nil;
    }
    
}

In this code I have two array on is listofPoint for storage only latitude and longitude of source bad destination points, and another is ListofSteps1 for storage of latitude and longitude of middle points of source and destination. Now I want to add all latitude and longitude in a single array. So how store in single array?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:53:44+00:00Added an answer on May 24, 2026 at 10:53 pm

    If you want to store both points into one array only there are several possibilities:

    1. create a new class which contains the two points as one element and add an instance of such a class (most probable the cleanest way)

    2. If you know that you always store two points for each entry you can just add these and access the the nTh pair by arrayIndex = n*2; [myArray objectAtIndex: n] and [myArray objectAtIndex: n+1]

    3 you may also create a new class containing 1 point and an attribute which kind of point it is. But then you need to traverse the list always from the beginning (I am not sure this is what you want in your case)

    ps you release your slegObject. I don’t see that you do an alloc/init for it.

    is your problem rather a memory management issue?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently started looking into Google Charts API for possible use within the
So Google Analytics does not have an API that we can use to get
In a web app I have people enter their address, then I use Google's
I'm trying to use the google maps API to fetch direction times. I'm hoping
I have been trying to use the hibernate dialect for SQLite from http://code.google.com/p/hibernate-sqlite/ in
I have a Python Facebook project hosted on Google App Engine and use the
I have a little private Google code project. For a SCM I use Mercurial.
I'm just starting to learn AspectJ, and I have use-case for say, User login.
I have a question regarding map api. I was using the the google map
I need to use Google Maps (v3) to check whether an address typed into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.