windowsforms-16767-controls-and-libraries-map-control-examples-gis-data-searching-how-to-create-a-custom-search-panel.md
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.
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.
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);
}
}
}
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraMap
Namespace MapControl_SearchPanel
Partial Public Class Form1
Inherits Form
Private ReadOnly Property SearchLayer() As InformationLayer
Get
Return CType(mapControl1.Layers("SearchLayer"), InformationLayer)
End Get
End Property
Private ReadOnly Property SearchProvider() As BingSearchDataProvider
Get
Return CType(SearchLayer.DataProvider, BingSearchDataProvider)
End Get
End Property
Public Sub New()
InitializeComponent()
AddHandler SearchLayer.DataRequestCompleted, AddressOf SearchLayer_DataRequestCompleted
End Sub
Private Sub SearchLayer_DataRequestCompleted(ByVal sender As Object, ByVal e As RequestCompletedEventArgs)
mapControl1.ZoomToFitLayerItems()
End Sub
Private Sub bSearch_Click(ByVal sender As Object, ByVal e As EventArgs) Handles bSearch.Click
SearchProvider.Search(teKeyword.Text)
End Sub
End Class
End Namespace