0

I've read and tested hundreds of samples and suggestions, but none of them seem to work for me.

Using winForms webControl I'm trying to pass in to the google maps api an array of addresses where will make a stop on the way.

Without the stops array everything works just fine. Here is the code samples:

JavaScript:

 function calcRoute(origin,destination, way ) 
 {
 var waypts = [];

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

VB.net

   Private Sub GetDirections_Click(sender As Object, e As EventArgs) 
        Dim origin As String = "1 Main St"
        Dim destination As String = "200 Main St"
        Dim wayP = New System.Web.Script.Serialization.JavaScriptSerializer().Serialize({"123Main St.", "189 Main St"})
        InvokeScript("calcRoute", origin, destination, wayP)
    End Sub

    Private Function InvokeScript(name As String, ParamArray args As Object()) As Object
        Return WebBrowser1.Document.InvokeScript(name, args)
    End Function

EDIT: the output I need to get in javascript is:

        [{
          location:"10201"
        },
        {
          location:"10202"
        }]
7
  • someone here has anything to add? any suggestion? – Commented Mar 26, 2014 at 2:48
  • What is your expected output? Commented Mar 26, 2014 at 3:36
  • I added a sample array output in the question. Commented Mar 26, 2014 at 14:18
  • You're inputing an array of strings and expecting to get an array of objects out. You need to create a simple class with a location property, and serialize an array of those objects. Commented Mar 26, 2014 at 14:24
  • 1
    Got it... stackoverflow.com/questions/1086404/string-to-object-in-js, @Smeegs please post you're comment as an answer so I could accept it and close that. Commented Mar 26, 2014 at 16:08

1 Answer 1

1

You're inputing an array of strings and expecting to get an array of objects out. You need to create a simple class with a location property, and serialize an array of those objects.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.