Code Monkey home page Code Monkey logo

Comments (9)

moshen avatar moshen commented on July 24, 2024

Have you tried something like the example query in the docs here:
https://developers.google.com/maps/documentation/directions/?csw=1#Waypoints
?

You can pass either pipe separated textual destinations or lat,lng.

from node-googlemaps.

Kodextor avatar Kodextor commented on July 24, 2024

I tried calling the url directly... I will try to check this later and will let you know... Thanks though..

from node-googlemaps.

leandroz avatar leandroz commented on July 24, 2024

Hi!, i am trying to use the directions services with waypoints. The origin and destination are the same address and then i have two more address in an array with location like this:
var WayPoints = [{location: recogida },{location: destino}];
Where recogida and destino are both adresses.
When i call the function and i passed the waypoints array as 6th argument, appears like the directions service is not using the waypoints, because i receive a response without waypoint_order and the overview_polyline is only the origin and destination point (are the same). Is working ok?

from node-googlemaps.

fabriziomoscon avatar fabriziomoscon commented on July 24, 2024

@leandroz the direction function has changed:
https://github.com/moshen/node-googlemaps/blob/master/lib/googlemaps.js#L148

if you can provide a test for your case we can look into the issue

from node-googlemaps.

leandroz avatar leandroz commented on July 24, 2024

The problem is with the function buildUrl, stringify and how you have to pass the arguments waypoints to Google Maps.
Here is the url example from Google Maps documentation:
http://maps.googleapis.com/maps/api/directions/json?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|Lexington,MA&sensor=false

See that each waypoints is separated by |, but stringify escaped an array like:

querystring.stringify({ foo: 'bar', baz: ['qux', 'quux'], corge: '' })
// returns
'foo=bar&baz=qux&baz=quux&corge='

If you prove the test with waypoints it will fail.
Thats the problem.

from node-googlemaps.

fabriziomoscon avatar fabriziomoscon commented on July 24, 2024

I think this is the same issue as #49

I can see a possible confusion arising when people think waypoints is an array, whereas passing a string will make it work.

Have I understood the problem correctly @leandroz ?

from node-googlemaps.

leandroz avatar leandroz commented on July 24, 2024

Hi @fabriziomoscon !
I am passing the waypoints like this

[{location: LatLngOrigin}, {location: LatLngDestination }]

What is the proper way to do it?

from node-googlemaps.

leandroz avatar leandroz commented on July 24, 2024
LatLngOrigin + "|" + LatLngDestination

Is the right way?

from node-googlemaps.

fabriziomoscon avatar fabriziomoscon commented on July 24, 2024

Google expects waypoints as a string of pipe separated locations. An the library doesn't have any conversion for the input you pass.

Please pass something similar to:

var waypoints = "Charlestown,MA|Lexington,MA";

from node-googlemaps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.