
Adding a Find Control to a Map
The fastest and easiest way to allow users to find business or addresses is to add a Find Control to a map. Add the following line to Listing 1 after the call to LoadMap loads the page.
Listing 2: Enabling the Find control
You should see the classic "What/Where" box in the upper right corner of your map. Type in a category of business or a location, or both, and the results appear on the map, as in Figure 1.
.jpg)
Figure 1: Finding information with the Find control
As you move the map around, the search automatically refreshes itself for the given area. Behind the scenes, the VEMap control is using AJAX to repeatedly call the Microsoft servers and performing a search against the very large yellow pages directory hosted with the Bing Maps maps.
Although the built in Find Control is easy to use and powerful, there are some limitations. Most notably, the control itself is visually uninspiring and difficult to change. Also, if a user enters an ambiguous location, they see a disambiguation dialogue window similar to the following.
.jpg)
Figure 2: A disambiguation dialog
Although you can turn the disambiguation off, forcing Bing Maps to always pick what it considers to be the best match, users may see unexpected results. For example, unless the user is from Kansas or is a fan of Kansas State University, they are more likely to expect a search for Manhattan to return a result in New York City (the 2nd and 3rd closest choices).
To disable this disambiguation dialog window, add the following line of code.
map.ShowDisambiguationDialog(false);
Listing 3: Turning off automatic disambiguation
Although this does fix the disambiguation issue, you are still left with a Find Control that you can't easily change. That's where the Find method comes in.