iniamudhan / react-bingmaps

Bingmaps in React.js
MIT License
26 stars 42 forks source link

Can't Display Truck Route Directions #23

Open ken92 opened 6 years ago

ken92 commented 6 years ago

I've been messing with the Bing Maps API with Postman and comparing what react-bingmaps is sending and it appears that for whatever reason, when routeMode is set to truck, Bing Maps will return an error if isViaPoint is set to null. I've tried to set it to true, 1, 0, "1", "0", "true", "false"`, but any falsy value is being automatically set to null in the code.

An easy fix would be to replace this:

var isViaPoint = wayPoints[wayPointsIndex].isViaPoint ? wayPoints[wayPointsIndex].isViaPoint : null;

with this:

var isViaPoint = wayPoints[wayPointsIndex].isViaPoint !== undefined ? wayPoints[wayPointsIndex].isViaPoint : null;

That way, users can pass falsy values and it will be passed on to the Bing Maps API as they intend.

Alternatively, if anyone knows how to get this to work without modifying the repo, I'm all ears.

ken92 commented 6 years ago

I tested this in my own code and it solves my use case's problem. I can now view truck routes in my map! :)

ken92 commented 6 years ago

@iniamudhan Any chance I can get an approval on this? My code needs to go into QA soon and I don't really want to make my own spin-off of your repo just for this one line fix.

ken92 commented 6 years ago

My code needs to go into QA today, it turns out. In the meantime, I've created this package with this fix in it. Currently, there are no other differences.

https://www.npmjs.com/package/@possumsnorts/react-bingmaps

dillonbartkus commented 5 years ago

How are you able to get truck routes to show? I can do driving and transit, but when I change routeMode to truck I get an error:

"errorDetails": [ "One or more parameters are not valid.", "waypoint: Parameter is missing" ]