Geography Reference
In-Depth Information
VectorLayer highlightLayer = ( VectorLayer )
mpbMapView.Map.FindLayer( "highlight" ).FirstOrDefault();
if (highlightLayer == null )
{
Color myColor = Color .FromArgb(64,144,238,144);
Brush fillBrush = new SolidBrush (myColor);
highlightLayer = new VectorLayer ( "highlight" );
VectorStyle highlightStyle = new VectorStyle
{Fill = fillBrush, Outline = Pens .White, EnableOutline = true };
highlightLayer.Style = highlightStyle;
}
We do this by first checking to see if we already have a highlight layer on our map. If one is
not present, create a new one. One thing to note about setting the style on the highlight layer
is the way we set the color. We use the full ARGB color call so that we can specify a
transparency level to our layer—the first value in the function, 64 —that allows us to see the
existing map elements underneath it.
Next we take the FeatureDataSet we obtained earlier and assign it as the data source for
our highlight layer so that the selected county polygon shows up with our defined semi-
transparent style. Note that this will highlight multiple polygons if you select more than one
on the map. Previously selected counties will be cleared.
highlightLayer.DataSource = new GeometryProvider (selectedGeometry.Tables[0]);
mpbMapView.Map.Layers.Add(highlightLayer);
mpbMapView.Refresh();
Once we add the highlight layer and refresh the map, our selected county should be visible.
The last thing to do for our country query feature is add our county info to the list box on the
left of our UI, and add some code at the start and end of the method to show what's
happening in our status bar.
lsbCountyResults.Items.Clear();
lsbCountyResults.Items.Add( "Selected county: " + countyName.ToUpper());
lsbCountyResults.Items.Add( "" );
Search WWH ::




Custom Search