Reputation: 2210
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"
}]
Upvotes: 0
Views: 592
Reputation: 9224
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.
Upvotes: 1