Hi James,
Thanks for your reply.
Below is source code which I have written to find the "Amreli" location.
First, I have create one .dbf file which contain "Amreli" location with longitute and latitue of "Amreli". I have attached the Data.zip file which contains Data.dbf.
Second, I have created on demo applicaiton which source code as below.
private void Form1_Load(object sender, EventArgs e)
{
// Setting up the map unit and set the Chicago extent
winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
winformsMap1.CurrentExtent = new RectangleShape(-125, 50, -66, 23);
// Create the overlay and add it to the map
LayerOverlay mainOverlay = new LayerOverlay();
winformsMap1.Overlays.Add("mainOverlay", mainOverlay);
// Setup the World Map Kit WMS Overlay
WorldMapKitWmsDesktopOverlay worldMapKitOverlay = new WorldMapKitWmsDesktopOverlay();
winformsMap1.Overlays.Add("WorldMapKitOverlay", worldMapKitOverlay);
// Setup the marker overlay and add it to the map
LayerOverlay markerOverlay = new LayerOverlay();
winformsMap1.Overlays.Add("MarkerOverlay", markerOverlay);
// Setup the marker layer
InMemoryFeatureLayer markerLayer = new InMemoryFeatureLayer();
markerLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
markerLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimplePointStyle(PointSymbolType.Circle, GeoColor.SimpleColors.Red, 10);
markerOverlay.Layers.Add("MarkerLayer", markerLayer);
winformsMap1.Refresh();
}
private void button1_Click(object sender, EventArgs e)
{
ThinkGeo.MapSuite.MapSuiteGeocoder.Geocoder geocoder = new ThinkGeo.MapSuite.MapSuiteGeocoder.Geocoder();
geocoder.MatchingPlugIns.Add(new CityDbfMatchingPlugin(@"C:\GIS R & D\india\Data.dbf"));
// Open the geocoder, get any matches and close it
Collection geocoderMatches;
try
{
geocoder.Open();
geocoderMatches = geocoder.Match(textBox1.Text);
InMemoryFeatureLayer markerLayer = winformsMap1.FindFeatureLayer("MarkerLayer") as InMemoryFeatureLayer;
if (geocoderMatches.Count > 0)
{
lstResult.Items.Clear();
lstResult.Items.Add(geocoderMatches[0].ToString());
PointShape pointShape = new PointShape(geocoderMatches[0].NameValuePairs["CentroidPoint"]);
winformsMap1.Overlays["MarkerOverlay"].Lock.EnterWriteLock();
try
{
markerLayer.Open();
markerLayer.EditTools.BeginTransaction();
markerLayer.EditTools.Add(new Feature(pointShape));
markerLayer.EditTools.CommitTransaction();
}
finally
{
markerLayer.Close();
winformsMap1.Overlays["MarkerOverlay"].Lock.ExitWriteLock();
}
winformsMap1.CurrentExtent = new RectangleShape(geocoderMatches[0].NameValuePairs["BoundingBox"]);
winformsMap1.Refresh();
}
}
finally
{
geocoder.Close();
}
}
<geocodermatch></geocodermatch>
After run the Application I am able to see map on screen and enter value in Text Box "Amreli" and click on button but I am not find location "Amreli" on map. (geocoderMatches.Count = 0) can you please guide where is my mistake or is it correct format .dbf file?
Waiting for your kindly response.
Thanks in advance.
Anish Patel.
001_Data.zip (255 Bytes)