Getting Distance Matrix API results to come out in a table.

108 views
Skip to first unread message

William Adams

unread,
Jun 30, 2011, 4:12:10 PM6/30/11
to google-maps-ap...@googlegroups.com
I was wondering how I could get the Distances in the Matrix API to come out in a table, like
 
Destination 1 / Destination 2 / Destination 3 / Destination 4 / Destination 5
Distance 1    / Distance 2     / Distance 3     / Distance 4    / Distance 5
 
I have tried using html tags and have gotten close but it never seems to seperate into different columns it just can seperate in rows. any ideas.

Barry Hunter

unread,
Jul 1, 2011, 10:36:47 AM7/1/11
to google-maps-ap...@googlegroups.com
The blog post contains one example of plotting the results in a table


I would suggest the Javascript Maps API group would be a btter fit for this question. Dont forget to read their posting guidelines. 


--
You received this message because you are subscribed to the Google Groups "Google Maps API Web Services" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-api-web-services/-/Llm2CQfQgr8J.
To post to this group, send email to google-maps-ap...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-api-web-...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-api-web-services?hl=en.

William Adams

unread,
Jul 1, 2011, 11:31:27 AM7/1/11
to google-maps-ap...@googlegroups.com
Unfortionatly I do not meet the guidelines to post there.  Unfortionatly the blog was not helpful either.  
 
          for (var i = 0; i < origins.length; i++) {
            var results = response.rows[i].elements;
            addMarker(origins[i], false);
            for (var j = 0; j < results.length; j++) {
              addMarker(destinations[j], true);
              outputDiv.innerHTML += results[j].distance.text ;
            }
          }
        }
      } 
 
Is the part of the code that makes the string of mileage
 
and this is what displays it.
    <div id="outputDiv"></div>
 
So how can I seperate results by columns?
 

William Adams

unread,
Jul 1, 2011, 11:34:21 AM7/1/11
to google-maps-ap...@googlegroups.com
Oh it may help to put the output  
 
121 mi155 mi66.3 mi104 mi157 mi126 mi100 mi212 mi254 mi192 mi245 mi129 mi191 mi269 mi

and I have the destination names written in a table above.

 

Barry Hunter

unread,
Jul 1, 2011, 12:33:24 PM7/1/11
to google-maps-ap...@googlegroups.com
On Fri, Jul 1, 2011 at 4:31 PM, William Adams <blindha...@gmail.com> wrote:
>
> Unfortionatly I do not meet the guidelines to post there.

What an earth does that mean?

Anyway I suspect you need to do some basic javascript and html learning
http://www.google.com/search?q=create+html+table+javascript
http://www.google.com/search?q=javascript+tutorial
http://www.google.com/search?q=javascript+dynamically+create+table

Use javascript to create a html table is probably the easiest.

>
>
> --
> You received this message because you are subscribed to the Google Groups "Google Maps API Web Services" group.

> To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-api-web-services/-/aNMo9Jz77IcJ.

William Adams

unread,
Jul 6, 2011, 8:44:34 AM7/6/11
to Google Maps API Web Services
What that means is my question will not be approved for that forum,
since my question is about the webservices and not api3, and I have a
good knowledge base of html, and a good working understanding of
jscript but the usual way of doing stuff is not working.

On Jul 1, 11:33 am, Barry Hunter <barrybhun...@gmail.com> wrote:
> On Fri, Jul 1, 2011 at 4:31 PM, William Adams <blindhawkey...@gmail.com> wrote:
>
> > Unfortionatly I do not meet the guidelines to post there.
>
> What an earth does that mean?
>
> Anyway I suspect you need to do some basic javascript and html learninghttp://www.google.com/search?q=create+html+table+javascripthttp://www.google.com/search?q=javascript+tutorialhttp://www.google.com/search?q=javascript+dynamically+create+table
>
>
>
>
>
>
>
> > Unfortionatly the blog was not helpful either.
>
> >           for (var i = 0; i < origins.length; i++) {
> >             var results = response.rows[i].elements;
> >             addMarker(origins[i], false);
> >             for (var j = 0; j < results.length; j++) {
> >               addMarker(destinations[j], true);
> >               outputDiv.innerHTML += results[j].distance.text ;
> >             }
> >           }
> >         }
> >       }
>
> > Is the part of the code that makes the string of mileage
>
> > and this is what displays it.
> >     <div id="outputDiv"></div>
>
> > So how can I seperate results by columns?
>
> Use javascript to create a html table is probably the easiest.
>
>
>
>
>
> > --
> > You received this message because you are subscribed to the Google Groups "Google Maps API Web Services" group.
> > To view this discussion on the web visithttps://groups.google.com/d/msg/google-maps-api-web-services/-/aNMo9J....
> > To post to this group, send email to google-maps-ap...@googlegroups.com.
> > To unsubscribe from this group, send email to google-maps-api-web-...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/google-maps-api-web-services?hl=en.- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages