Showing posts with label .NET Framework 2. Show all posts
Showing posts with label .NET Framework 2. Show all posts

31 March, 2008

Highlighting features with ArcGis Server 9.2

I have the need to highlight items when the user selects to zoom to a particular item from a custom search. If I was using the ResultsTask control, then the user could simply check the checkbox next to the feature, and it would highlight. However, since the client doesn't like the treeview style of the ResultsTask, I have put the search results into an HTML table. Now, when the user selects to zoom to a feature, it will automatically highlight the feature.

I found this code in the ESRI forums, and it works well.

// This gives us a nice light blue color. You can change the color to whatever you want.
ESRI.ArcGIS.ADF.ArcGISServer.RgbColor irgbc = new ESRI.ArcGIS.ADF.ArcGISServer.RgbColor();
irgbc.Red = 50;
irgbc.Green = 255;
irgbc.Blue = 255;
irgbc.AlphaValue = 255;

ESRI.ArcGIS.ADF.ArcGISServer.FIDSet fids = new ESRI.ArcGIS.ADF.ArcGISServer.FIDSet();
int[] ids = new int[1];
ids[0] = Convert.ToInt32(key); //<-- OBJECTID of the feature to highlight
fids.FIDArray = ids;

ESRI.ArcGIS.ADF.ArcGISServer.MapDescription mapdesc = ((MapFunctionality)mf).MapDescription;
ESRI.ArcGIS.ADF.ArcGISServer.LayerDescription[] layerdescs = mapdesc.LayerDescriptions;
ESRI.ArcGIS.ADF.ArcGISServer.LayerDescription layerdesc = layerdescs[layerid];
layerdesc.Visible = true;
layerdesc.SelectionColor = irgbc;
layerdesc.SelectionFeatures = fids.FIDArray;

The problem with the above code is that it highlights the entire area. Not bad for point features, but for polygons, it covers everything underneath it completely. I tried adjusting the RgbColor.AlphaValue, but that didn't change anything at all. I'm thinking that is a red herring, and doesn't really do anything at all. So what I decided to do was instead of filling the entire polygon, I just use ShowSelectBuffer as seen below:

ESRI.ArcGIS.ADF.ArcGISServer.RgbColor irgbc = new ESRI.ArcGIS.ADF.ArcGISServer.RgbColor();
irgbc.Red = 50;
irgbc.Green = 255;
irgbc.Blue = 255;
irgbc.AlphaValue = 255;

ESRI.ArcGIS.ADF.ArcGISServer.FIDSet fids = new ESRI.ArcGIS.ADF.ArcGISServer.FIDSet();
int[] ids = new int[1];
ids[0] = Convert.ToInt32(key);
fids.FIDArray = ids;

ESRI.ArcGIS.ADF.ArcGISServer.MapDescription mapdesc = ((MapFunctionality)mf).MapDescription;
ESRI.ArcGIS.ADF.ArcGISServer.LayerDescription[] layerdescs = mapdesc.LayerDescriptions;
ESRI.ArcGIS.ADF.ArcGISServer.LayerDescription layerdesc = layerdescs[layerid];
layerdesc.Visible = true;
layerdesc.ShowSelectionBuffer = true;
layerdesc.SelectionFeatures = fids.FIDArray;



By using LayerDescription.ShowSelectBuffer, the feature is outlined with the highligh color, instead of filled in. This gives us the ability to see what is within the feature, while still knowing where the feature was located.



References:



http://forums.esri.com/Thread.asp?c=158&f=2276&t=211190&mc=12#msgid719661



http://forums.esri.com/Thread.asp?c=158&f=2276&t=223224&mc=1




29 October, 2007

ESRI 9.2 lacks info regarding VS 2005

ESRI seems to like to play things very close to the vest - so to speak. It is difficult to find information on just about anything dealing with creating class libraries in .NET to work with ArcGIS 9.2, even though they tout that 9.2 is built on the .NET Framework 2.0. So far, 99% of the articles, tutorials or help I have found have been for pre-9.2 and VS 2003 (Framework 1.1).

To be fair, I have found a few PDF files discussing 9.2 and .NET 2.0, but that is about it. They are actually PDFs made from PowerPoint slides that I'm certain were from some conference or demonstration given probably a year or so ago. But the walkthroughs they have on their site for VS 2003 - which seem exceptional in detail - are conspicuously missing for VS 2005. Everything I have found that deals with VS 2005 centers around the ArcGIS SDK which , of course, didn't get installed on my system along with ArcGIS 9.2, and is not downloadable from ESRI - which I find strange. It seems to me that other companies make their SDK readily available to developers, but ESRI doesn't seem to want to play that game for some reason.

So here I am, about a week into the project. I've got most of the VBA code translated, but I can't test any of it because I can't get the crap to work properly in ArcMap, and I can't find any decent assistance on the 'net. I guess I'm going to have to go be the quintessential n00b at the ESRI forums and beg for some sort of help. I hate doing that, but, like Duke Wayne said "A man's gotta do what a man's gotta do" ( or someone said that anyway ).

Here are the walkthrough/tutorials that I found pertaining to ESRI and .NET if anyone is interested/needs them:

The way I'm looking at this right now, It seems like it would be infinitely easier to create a desktop app and add the ArcMap to the app, instead of trying to create modules to run in ArcMap. But that isn't the way things are right now, so I've gotta do what they want done.




Technorati Tags: , , ,