react-static-google-map icon indicating copy to clipboard operation
react-static-google-map copied to clipboard

Direction Component with waypoints

Open CScott0905 opened this issue 3 years ago • 3 comments

I'm trying to utilise the Direction component to render a static image that goes from A -> D via B & C I can see the directions API supports this via the waypoints param but when i pass this to the direction component nothing happens is there a way to get this functionality currently with the Direction component?

Unfortunately i do need the route rather than path so using the path component to handle this is not sufficient

CScott0905 avatar Jul 08 '20 22:07 CScott0905

I can see in this line https://github.com/bondz/react-static-google-map/blob/593f40137a3df3f37c370f6c897614245dd078da/src/strategies/direction/index.js#L67 that we do take in waypoints from props and pass it to the strategy.

But on this line in the strategy, you can see that we are not using the waypoints (or many other props) https://github.com/bondz/react-static-google-map/blob/593f40137a3df3f37c370f6c897614245dd078da/src/strategies/direction/nativeStrategy.js#L2

Both the nativeStrategy and the fetchStrategy should be updated to handle all of the directions props/options passed to them, unless @bondz has a reason they were not initially implemented. I believe he mentioned that the Directions component was added on later and kind of an "after thought", so its likely they weren't implemented simply for that reason.

I am travelling for the next two weeks. But when I get home I should be able to take a look at this.

@CScott0905 you can currently accomplish this by passing a promise to requestStrategy. Take a look at this line: https://github.com/bondz/react-static-google-map/blob/593f40137a3df3f37c370f6c897614245dd078da/src/strategies/direction/index.js#L78 You can then take a look at the native and fetch strategies and see that they are basic calls to the google directions API and you can create your own.

DaddyWarbucks avatar Jul 09 '20 20:07 DaddyWarbucks

Yes @DaddyWarbucks, it was an oversight. The directions component was a POC to prove that you could render directions async to a path and because the user could implement their own strategy to get the directions, the implementation was not prioritized. Wishing you safe travels @DaddyWarbucks

A workaround is to implement your own strategy @CScott0905 like @DaddyWarbucks showed until all the other props for Directions are handled by the built in strategies.

bondz avatar Jul 09 '20 21:07 bondz

@DaddyWarbucks @bondz thank you for the quick response I will try the above thank you.

CScott0905 avatar Jul 10 '20 12:07 CScott0905