Problem Finding Info - URGENT

Hello Friends,

In my code, it shows Results as null on callback. Though it finds the location, map goes over there but on callback method it shows resuls as null and returns to the original map. Can nyone please help me figure out the problem. I am in a very critical condition.

This is my code - Default.aspx

Code Snippet

DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>My Virtual Earth Application</< FONT>title>

<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>

<scriptsrc="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5"type="text/jscript"></< FONT>script>

<scriptsrc="js/Default.aspx.js"type="text/javascript"></< FONT>script>

</< FONT>head>

<body>

<formid="findForm"runat="server">

<asp:TableID="HeaderTable"runat="server"Width="705px">

<asp:TableRowrunat="server">

<asp:TableCellrunat="server"><h1id="headTitle"style="color:Fuchsia">My Virtual Earth</< FONT>h1></< FONT>asp:TableCell>

<asp:TableCellrunat="server">

<divstyle="position:inherit; left:100px; width:300px; height: 30px;">

<fieldset>

<divid="whatContainer"class="inactiveTextBox">

<inputid="what"name="what"type="text"title="Search for a business or category"

value=""style="width:200;"/>

</< FONT>div>

<divid="whereContainer"class="inactiveTextBox">

<inputid="where"name="where"type="text"title="Enter city, address, or landmark"

value=""style="width:200px;"/>

<inputid="searchbttn"type="submit"title="Search"value="Find"style="width:50px;"onclick="FindWhatWhere();"/>

</< FONT>div>

</< FONT>fieldset>

</< FONT>div>

</< FONT>asp:TableCell>

</< FONT>asp:TableRow>

</< FONT>asp:Table>

<asp:DropDownListID="CollectionsDropDownList"runat="server">

<asp:ListItem>Add Pushpins</< FONT>asp:ListItem>

</< FONT>asp:DropDownList>

<asp:DropDownListID="ShareDropDownList"runat="server">

<asp:ListItem>Send Email</< FONT>asp:ListItem>

</< FONT>asp:DropDownList>

<inputid="routeBtn"name="routeBtn"type="button"value="Route Directions"onclick="createDrivePanel()"/>

<divid="msve_TaskArea_positioner"class="expanded1">

<divid="msve_TaskArea_transparency">

<divid="msve_TaskArea_data">

</< FONT>div>

</< FONT>div>

<divid="msve_TaskArea_gutter"class="mid">

<asp:PanelID="ButtonsPanel"runat="server"BorderStyle="Dashed"Direction="RightToLeft"

Height="50px"Width="883px"Wrap="False">

<inputid="addPushPinBtn"style="background-position: center center; background-image: url(images/Pushpin.bmp);

width: 27px; background-color: transparent"title="Add Pushpin"type="button"onclick="crearePushpinPanel();"/>

<inputid="sendMailBtn"style="background-position: center center; background-image: url(images/mail.bmp);

width: 23px; background-color: transparent"title="Send EMail"type="button"/>

<inputid="zoomOutButton"style="background-image:url(images/ZoomOut.bmp); background-position: center center; width: 25px; background-color: transparent;"type="button"onclick="DoZoomOut();"title="Zoom Out"/>

<inputid="zoomInBtn"runat="server"type="button"onclick="DoZoomIn();"style="background-position: center center; background-image: url(images/ZoomIn.bmp); width: 23px; background-color: transparent"title="Zoom In"/>

<inputid="panDwnBtn"runat="server"type="button"onclick="DoPanDown();"style="background-position: center center; background-image: url(images/PanDown.bmp); width: 26px; background-color: transparent"title="Pan Down"/>

<inputid="panRgtBtn"runat="server"type="button"onclick="DoPanRight();"style="background-position: center center; background-image: url(images/PanRight.bmp); width: 25px; background-color: transparent"title="Pan Right"/>

<inputid="panLeftBtn"runat="server"type="button"onclick="DoPanLeft();"style="background-position: center center; background-image: url(images/PanLeft.bmp); width: 28px; background-color: transparent"title="Pan Left"/>

<inputid="panUpBtn"runat="server"type="button"onclick="DoPanUp();"style="background-position: center center; background-image: url(images/PanlUp.bmp); width: 30px; height: 24px; background-color: transparent"title="Pan Up"/>

<inputid="birdsEyeBtn"runat="server"type="button"value="B E"onclick="ShowBEView();"disabled="disabled"/>

<selectid="mapStyle"name="mapStyle"onchange="ChangeStyle();">

<optionvalue="r"selected="selected">Road</< FONT>option>

<optionvalue="a">Aerial</< FONT>option>

<optionvalue="h">Hybrid</< FONT>option>

</< FONT>select>

<inputid="3dBtn"name="3dBtn"type="button"value="3D"/>

<inputid="2dBtn"name="2dBtn"type="button"value="2D"/>

</< FONT>asp:Panel>

</< FONT>div>

</< FONT>div>

</< FONT>form>

<divid='mymap'style="position:absolute; left:300px; width:600px; height:550px; border:#555555 2px solid; top: 182px;"runat="server"></< FONT>div>

<divid='inMap'style="position:relative; width:200px; height:200px; left:689px; top: -588px;"></< FONT>div>

<divid="directDIV"class="directDIV"style="width: 273px; position: absolute; height: 550px; background-color:silver; left: 13px; top: 188px;">

<labelid="lbl"></< FONT>label>

</< FONT>div>

<asp:PanelID="ResultsPanel"runat="server"BorderStyle="Solid"Height="84px"ScrollBars="Auto"Width="104px">

</< FONT>asp:Panel>

<br/>

</< FONT>body>

</< FONT>html>

Default.aspx.js File

Code Snippet

// JScript File

// the Map object

var map =null;

var insertMap =null;

var latitude;

var longitude;

// Load the map

function Page_Load()

{

map =new VEMap('mymap');

map.LoadMap();

insertMap =new VEMap('inMap');

insertMap.LoadMap(new VELatLong(-33.7939, 151.1093), 2,'h',true);

map.AttachEvent("onendcontinuouspan", GetLatLong);

// map.AttachEvent("onendzoom", GetLatLong); // This line was giving error on Zooming

map.AttachEvent("onchangeview", OnChangeView);

map.AttachEvent("onclick", GetLatLong);

map

}

// Calulates Latitude and Longitude

function GetLatLong(e)

{

//Get the pixel coordinates of where the map was clicked

var x = e.mapX;

var y = e.mapY;

var pixel =new VEPixel(x, y);

var latlong = map.PixelToLatLong(pixel);

//Round the coordinates to 5 decimal places

latitude = Math.round(10000*latlong.Latitude)/10000;

longitude = Math.round(10000*latlong.Longitude)/10000;

// insertMap.PanToLatLong(new VELatLong(latitude, longitude));

}

// On Change View Event

function OnChangeView() {

if (map.IsBirdseyeAvailable())

document.getElementById('birdsEyeBtn').disabled =false;

else

document.getElementById('birdsEyeBtn').disabled =true;

}

// Change Map style view

function ChangeStyle() {

var style = document.getElementById('mapStyle').getAttribute('value');

if (style ==null)

style = document.getElementById('mapStyle').value;

map.SetMapStyle(style);

}

// Get and Validate Data to search

function FindWhatWhere() {

var what = document.getElementById('what').value;

var where = document.getElementById('where').value;

var index = 0;

if (what =="Search for a business or category")

what ="";

if (where =="Enter city, address, or landmark")

where ="";

alert("What = " + what +" Where = " + where);

if (what =="" && where =="") {

alert("Please Enter to Search and then click Find button");

}else {

FindItem(what, where, index);

}

}

// Find

function FindItem(what, where, index){

try {

map =new VEMap('mymap');

map.LoadMap();

// map.Find(what,where,null,null,index,20,true,true,false,true, ResultsFound); // // It searches & takes the map back to default map

map.FindLocation(where, ResultsFound);

alert("Find executed");

}catch(err) {

var txt ="Error executing Find \n Error: " + err.description;

alert (txt);

}

}

// Find Callback

function ResultsFound(results) {

if (results ==null)

alert ("Results are Null");

elseif (results.length <= 0)

alert("Results is ZERO");

else

alert("Results Found = ");

VEMap.IncludePointInView(map.GetCenter());

var pindid = 1;

var pin =new VEPushpin (pinID, map.GetCenter(),null,"John's office","Building 28");

map.AddPushpin(pin);

pinID++;

alert("Added");

// results += "\n These are the Results Found.";

// ResultsPanel.Controls.Add(results.length);

// DoAlert(results.length);

}

I enter stuff like, "Mumbai, India", "New York". This code shows me "What = where ="Mumbai, India", "Find Executed", takes the map to Mumbai & "Results are Null" & the map returns on original map.

It would be nice if you can help me out with this code to get the problem in it. Along with this Find, can u guide to add pushpins on multiple search. And how to deal with search by category, Local info, etc.

I would appreciate your help. Please help me out. I can't believe my Driving Directions are working v. well in 1st time but this simple Find takes a hell of time.

Thanks

Trupti Dalia

[42797 byte] By [TVD] at [2008-1-3]

Windows Live Developer Forums

Site Classified