Hi James,
Thank you for your help. What I have is an MDI form where the user can input a section, block, and lot number. These numbers are combined to form a unique ID. After the user enters these numbers and clicks a button, I would like the map to zoom into the selected lot which has the corresponding unique ID. I've included the code I have so far. Right now the "pID" variable is used to access the feature ID. Instead I would like this variable to access a column of unique IDs made up of the section, block, and lot numbers. I'm not sure I need a collection feature like you suggest as I only want to select one feature. I also do not know how to pass the "pID" variable to the CustomFeatureSource class. I'm a bit of a newbie with this. Thanks again!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ThinkGeo.MapSuite.Core;
using ThinkGeo.MapSuite.DesktopEdition;
namespace HelloWorld
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
string firstName = txtFirstName.Text;
string lastName = txtLastName.Text;
string section = txtSection.Text;
string block = txtBlock.Text;
string lot = txtLot.Text;
string pID;
WinformsMap winformsMap2 = (WinformsMap)this.Parent;
InMemoryFeatureLayer inMemoryFeatureLayer = new InMemoryFeatureLayer();
inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(200, GeoColor.SimpleColors.PastelRed)));
inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color = GeoColor.StandardColors.Red;
inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
LayerOverlay layerOverlay = new LayerOverlay();
layerOverlay.Layers.Add("QueryResultLayer", inMemoryFeatureLayer);
winformsMap2.Overlays.Add("QueryResultLayer", layerOverlay);
if (section.ToString() == "")
{
MessageBox.Show("Please enter Section number");
winformsMap2.Overlays.Remove("QueryResultLayer");
return;
}
else if (block.ToString() == "")
{
MessageBox.Show("Please enter Block number");
winformsMap2.Overlays.Remove("QueryResultLayer");
return;
}
else if (lot.ToString() == "")
{
MessageBox.Show("Please enter Lot number");
winformsMap2.Overlays.Remove("QueryResultLayer");
return;
}
else
{
pID = (section + block + lot);
}
selectLot(pID);
}
private void selectLot(string pID)
{
WinformsMap winformsMap2 = (WinformsMap)this.Parent;
ShapeFileFeatureLayer selection = new ShapeFileFeatureLayer(@"H:\temp2\elkland_lots.shp");
InMemoryFeatureLayer queryResultLayer = (InMemoryFeatureLayer)winformsMap2.FindFeatureLayer("QueryResultLayer");
selection.Open();
Feature feature = selection.QueryTools.GetFeatureById(pID, ReturningColumnsType.NoColumns);
RectangleShape rect = new RectangleShape();
selection.Close();
queryResultLayer.InternalFeatures.Clear();
queryResultLayer.InternalFeatures.Add(feature.Id, feature);
queryResultLayer.Open();
rect = queryResultLayer.GetBoundingBox();
queryResultLayer.Close();
rect.ScaleUp(200);
winformsMap2.CurrentExtent = rect;
winformsMap2.Refresh();
}
}
}