How to: Create a Custom Search Panel
- 2 minutes to read
This example implements a custom search panel.
Create an InformationLayer object and assign it to the InformationLayer.DataProvider property. Specify the object’s BingMapDataProviderBase.BingKey property.
Note
This example does not use the built-in search panel, so the Map
Search property is set to false.Panel Options. Visible - Build a custom search panel. In this example, the search panel includes two text edits (for keyword and location) and a Search button.
- Call the BingSearchDataProvider.Search method in the Search button’s
Click
event handler.
Note
Refer to How to: Get a Bing Maps Key if you run the application and see a window with the following error message: “The specified Bing Maps key is invalid. To create a developer account, refer to https://www.
using System;
using System.Windows.Forms;
using DevExpress.XtraMap;
namespace MapControl_SearchPanel {
public partial class Form1 : Form {
InformationLayer SearchLayer { get { return (InformationLayer)mapControl1.Layers["SearchLayer"]; } }
BingSearchDataProvider SearchProvider { get { return (BingSearchDataProvider)SearchLayer.DataProvider; } }
public Form1() {
InitializeComponent();
SearchLayer.DataRequestCompleted += SearchLayer_DataRequestCompleted;
}
void SearchLayer_DataRequestCompleted(object sender, RequestCompletedEventArgs e) {
mapControl1.ZoomToFitLayerItems();
}
private void bSearch_Click(object sender, EventArgs e) {
SearchProvider.Search(teKeyword.Text);
}
}
}