Depends on how your data is stored. When you have a database with fields that are called lat
and lng
then you can use them directly. You can also use a Repeat to create an array and set values in them (don’t forget to check the Output).
Thanks a lot, have lat, lng in database so will give it a try
Thanks @patrick and @Hyperbytes for all the help.
Not involved into that topic, but hey thats an amazing support from you @patrick
BTW: Never saw such a nice healthy growing helpful community!
i see the question about accessing the data in js more than once in the forums.
it will be greatly appreciated if you guys put some documentation on the subject
Hate to be a pest @patrick but i have set up lat/lng in array as you suggested
and I know that part is working correctly as i can see them output via a repeat:
but i dont seem to be able to get them passed to the dynamic way points.
server action returns:
What would my data binding be here?
Waypoints requires an array, since your query already contains the lat/lng you don’t need the repeat. You can use serverconnect1.data.query1
as expression for the waypoints. Don’t forget to also have an origin and destination, these are required.
If you don’t get it working then send me a message with a link to a sample page which I could check. If it is a problem with the plugin then I will update it.
Thanks @patrick, when you have a spare few minutes, not urgent, can you have a look at this please.
I would love to get it working and add a new how to to the site as it is an obvious gap.
https://findmystudentdigs.co.uk/testing.php
I have listed the results of the data queries in tables for you information to hopefully assist.
As soon as I remove the static parameters and add dynamic parameters the directions info breaks
The origin and destination only accept an object or string, not an array. Try changing the expressions for the origin and destination to conn_origin.data.query1[0]
and conn_destination.data.query1[0]
.
Done, no difference
(FYI deliberately started at how wappler sets things by default in the plugin, thought it best place to start)
Ok, found the reason.
First is that directions has a Dynamic Update flag, this must be set when you have dynamic data that updates after initial load, like when you get your data from serverconnect.
Second is the data type, the lat and lng values must be numbers, in your case these are strings. What are the field types in the database?
I will update the extension to always convert the lat/lng to a number, so that it doesn’t matter in which field type you store it.
Thanks Patrick
Normally have the dynamic update flag set, must have switched it off when trying to get it working and not noticed. Set now (still not working)
lat, lng are decimal (12.8) at present in table
Seems that PHP PDO returns Fixed-Point types (DECIMAL, NUMERIC) as strings. Also BIGINTs can be returned as string. So I will update the google maps and directions plugins to work with string values in lat/lng also.
Thanks Patrick, you are a star as always. Once all updated I will do a “how to”.
Are you also going to change the default wappler behaviour for origin and destination to default to:
connection.data.query[0] rather than connection.data.query ?
The update is ready. I also let it accept array for origin and destination now, it will just take the first value from the array so that connection.data.query
will also work.
dmxGoogleDirections.zip (2.2 KB)
You really are a clever man, works a treat. Thank you again for your amazing work.
Thanks @patrick and @Hyperbytes.
Will sort out a tutorial over the weekend
Great work Brian and Patrick, this is definitely on my ‘wanted’ list. I need this for two reasons…
-
For a project to plan inspections for an engineer. He would be presented with say 6 locations as a list and then be required to plan his own route by dragging the location order. That would then be saved as his route for the day.
-
For my own roadtrip route planning as we love to drive around and see all parts of the UK. In this case I would start with an origin and destination, and would want to add intermediate waypoints by clicking on the map to add to the list, would this be possible? This is so I could plan a route to go on a particular road, through a certain scenic spot, or past a well-known landmark. And then change that order by dragging. Currently you cannot do this in Google and save it for use on a mobile device.
Great work guys.