-2

i have a question about using the waypoint feature ,i took the script from the User Geocodezip; very big thanks for that ,and it work well ,but

i can only route with waypoint ,i would like to have the waypoints as an option,but if the User let this field empty there is no funktion!? does anyone have an idea???

geocodezip
  • 158,664
  • 13
  • 220
  • 245
gungott
  • 231
  • 3
  • 9
  • 1
    What does _your_ code look like? What have you tried to implement the functionality you are looking for? What problems did you run into? – geocodezip Dec 07 '13 at 19:22
  • Hi ,and thx for, i tried to put it in jsfiddle .. tried "http://jsfiddle.net/gungott/X8gm4/ – gungott Dec 07 '13 at 20:06
  • I want build the code for Routing from A to B (only Start to End) AND for the option to insert Waypoints ,now it works only with waypoint(s) not just with A->B,i`m not sure where i can put the parameter for the Waypoints as a Option instead of a musthave ... sry my broken English .. – gungott Dec 07 '13 at 20:16
  • You already said that in your question. What does your code look like? (it should be, at least a [short self contained correct example](http://sscce.org/) of it, posted as part of your question). – geocodezip Dec 07 '13 at 20:21
  • :) sry but i am not very confirm with js think it has to do with these collumns var waypts = []; var waypointstring; var waypoint1 = document.getElementById('txtWaypoint').value; for (var i = 0; i < waypointstring.length; i++) { .... i will trie it out, thx for ure attention – gungott Dec 07 '13 at 21:47
  • The [example in the documentation](https://developers.google.com/maps/documentation/javascript/examples/directions-waypoints) does "optional" waypoints. – geocodezip Dec 08 '13 at 05:35
  • Finally i found the Solution : ` for (var i = 0; i < waypointstring.length; i++) { ` `var address = waypointstring[i]; if (address !== "") {` waypts.push({location:waypointstring[i], stopover:true}); } }` thanks for geozipcode for the for (var i = 0; i < waypointstring.length; i++) { var address = waypointstring[i]; if (address !== "") { waypts.push({location:waypointstring[i], stopover:true}); } } ` thanks geocodezip for the encouragement and spadework – gungott Dec 13 '13 at 19:56

1 Answers1

-1
    if (waypts.options[i].selected == true) {

i insert this line, to Element "waypts" becoming not a mandatory field, but now whole scripts have no funktion.

for (var i = 0; i < waypointstring.length; i++) {
if (waypts.options[i].selected == true) {
 waypts.push({location:waypointstring[i], stopover:true});
   }

}

Finally found the solution :

   var address = waypointstring[i];
if (address !== "") {

here is the whole source example

Community
  • 1
  • 1
gungott
  • 231
  • 3
  • 9
  • This is not an Answer, this should be part of your Question – duncan Dec 09 '13 at 09:41
  • oh ,yes u are right i just want to fill in some code, and take the wrong way ,,but now i tried this and it dont work,: `if(Waypoint[i].value = value` someone have an idea ?,i tried nearly 100 way for this record – gungott Dec 10 '13 at 20:19