Saturday, February 16, 2008

Tech Update: Rolling Up My Sleeves

Ok... this week has been full-on trouble shooting and learning how to make the code behind the software's engine do what I need it to do. I have programmed with Visual Basic in the past, so I'm comfortable with the VBA editor that comes with ArcGIS. On the other hand, the object model for ArcGIS is humongous! I've had success in the past using the object model, but it's always an adventure, and my success is owed entirely to the many support/help resources I've found. The fact is that many people have published their code online, so I haven't had to invent many wheels so far.

I'd like to take a second and share my sources, in case anyone out there is interested in coding ArcObjects but just starting out. And of course, any of you veterans who know of more/better sources, please send em my way.

First, I should mention that I do use my trusty copy of Getting To Know ArcObjects by Robert Burke a lot. But not nearly as much as online sources such as ArcObjects Online and The ESRI Developer Network, each of which offer a lot of documentation and code samples. But the ESRI User Forums is the goldmine. Usually my first stop - highly recommended and helpful.

So, what have I accomplished so far (with the help of these resources)? For starters, I have learned how to zoom to the boundary of a polygon, such as a neighborhood or a the boundary of zip code. The volunteers here might want to make a map of the Albany Park neighborhood. They can do this now with the click of a mouse, thanks to code which came largely from the Burke book.

I have also learned how to programatically geocode a custom address (although I have had problems refreshing the geocoded point to appear on the layout once it is added to its attribute table. Still unsolved but I'm not out of ideas.)

In fact, refreshing the map layout is more complicated - in general - than I had anticipated. A guy in India on the ESRI boards helped me troubleshoot my code when I was having a hard time accessing and refreshing the legend. (Thanks, Vijay!) Maybe this technique will shine light on why my geocoded point won't refresh. I'll get that fixed this coming week.

What else did I build this past week? There is now a way for the user to customize the title, add news text, and add credits/sources to the map. Again, this was a little more difficult than I suspected it would be, since the text objects' property dialogs do not let you give them unique IDs/Names... and you need to refer to the objects by name when accessing them programatically. No idea why you can't simply rename them in their property boxes. Turns out, I had to create a custom routine to name the components, one at a time, at the moment I created them. Strange, but it worked. (Drop me a line if anyone needs any of this code.) Moreover, I had to add code to add carriage returns to user text (news stories), in order to ensure the textbox object stays at the proper width in the layout. (If that makes sense.)

I have also learned how to access layers in the Table of Contents (toc), and how to toggle them on and off. Again, refreshing the toc is separate from refreshing the map... and then refreshing the legend - all of which have to occur when a layer is toggled on or off. But now that I can do all of this, adding the layers Dan needs (hospitals, schools, teacher/mentor program locations, etc.), and attaching them to the interface will be tedious but straight-forward.

Lastly, I should mention that a guy who lurks on our yahoo group TutorMentor_GIS_Project works for the city of Chicago, and contacted me with a donation of code that allows me to export map layouts to .pdf ... thanks!

That should get us up to date for the week. Here's a quick look at the interface in its current state:

See you next week.

Thoughts and prayers to everyone who lost their home in this week's fire at Cabrini Green. Heartbreaking story.

No comments: