Google Map distance calculation between multiple points -


i calculating distance , duration between origin (say a) , destination (say b) in java using google map api follows:-

distancematrixapirequest request = distancematrixapi.newrequest(context).origins(origin).destinations(destination); distancematrix result = request.await(); system.out.println("distance : "+result.rows[0].elements[0].distance.inmeters); system.out.println("duration : "+result.rows[0].elements[0].duration.humanreadable); 

however if want calculate duration , distance between multiple points (say --> b --> c --> d), how do this? should repeat above code between each of points or there better way this?

you can in single request:

  • origins: [a,b,c]
  • destinations: [b,c,d]

then ignore results don't need (you need a->b, b->c, c->d; not other combinations).


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -