Wednesday 6 May 2009

More with Virtual Earth

Continuing on from the previous post, lets do something very simple. A find query.

You can use the previous solution for this sample as well.

Create a new ASPX file and drag a map control into it. Also drag in a script manager if there is not one present on the page.


Now we are going to add some labels and text boxes and a button

<asp:Label ID="Label1" runat="server" Text="Find:"></asp:Label>&nbsp;
        <asp:TextBox ID="txtFind" runat="server"></asp:TextBox>&nbsp;
        <asp:Label ID="lblWhere" runat="server" Text="Where"></asp:Label>&nbsp;
        <asp:TextBox ID="txtWhere" runat="server"></asp:TextBox>&nbsp;
        <asp:Button ID="btnFind" runat="server" Text="Find This" onclick="FindStuff" />

Now in the code behind we have

protected void FindStuff(object sender, EventArgs e)
           string what = txtFind.Text;
           string where = txtWhere.Text;

           Map1.Find(what, where);

Now build the code and run it in the browser.

I used searched for Sushi in Manhattan, New York and it brought a couple of hits


You can find the updated solution file here

No comments: