Comment posted by
rowter
on Monday, March 22, 2010 3:41 PM
|
|
Hi,
I am working with Bing Maps on a windows form. I am using a webbrowser control to host my form.
From the webbrowser on my winform, my code looked like this.
WebBrowser1.Document.InvokeScript("GetRouteMap", New Object() {CObj(addr), CObj(addr2)})
WebBrowser1.Document.InvokeScript("GetMap", New String() {addr, addr2})// I tried all differet formats here.
Now in my javascript:
<body onload="GetMap(primAddr, secnAddr);" style="font-family:Arial">
<div id;='directions'></div>
<div id='myMap' style="position:relative; width:400px; height:400px;"></div>
</body>
function GetMap(primAddr,secnAddr)
{
map = new VEMap("myMap");
map.LoadMap();
//Location = new Array("5717 Ridgemont pl, Midland, TX", "6701 eastridge Rd, Odessa, TX");
alert("primAddr value is a type of : " + typeof(primAddr));
alert("secnAddr value is a type of : " + typeof(secnAddr));
//Location = new Array(a,b);
Location = new (primAddr, secnAddr);
try{
alert(Location[0]); ------------------------- Has the values that i passed from my form
alert(Location[1]); ------------------------- Has the values that i passed from my form
GetRouteMap(Location); ----------------Calling this function and passing the array.
}
catch (e) {
alert(e.name + "TestLocation1234" + e.message);
}
}
function GetRouteMap(Location)
{
var options = new VERouteOptions;
//options.DrawRoute = true;
options.RouteCallback = ShowTurns;
// options.ShowDisambiguation = false;
options.DistanceUnit = VERouteDistanceUnit.Mile;
var testroute = new VERoute;
alert(typeof(Location));
try{
alert(Location[0]); ------------------- Has the values that i passed from my form
alert(Location[1]); ------------------- Has the values that i passed from my form
map.GetDirections(Location, options); -------------Here this function is expecting an array so, i pass the array directly.
}
else{
alert("Location is not an array");
}
map.GetDirections(Location, options);
}
catch (e) {
alert("GetRouteMethod Erorr:" + e.name + " " + e.message);
}
}
This is failing for some reason. If i hardcode the address values it is working good. But, if i send the parameters, it is failing. Is there any mistake in my code? Not sure why this is erroring out for the parameters. I checked the parameters ad they are of string type.
Any idea what might be wrong?
Thanks