Well, this is my first post of what I am sure will be many. I've just started using Mappoint and thanks to the many good examples here I've been able to get a couple of polygons drawn programmatically onto the screen. Much Excedrin has been taken
I am attempting to loop through the vertices of the polygon and output their coordinates to the Immediate Window. Oh, sorry. I'm using Visual Basic 2005 and Mappoint 2006. I am also VERY new to VB 2005 and OOP ... needless to say there is lots of trial and error and sometimes code works and I don't know why.
Right now there is only 1 polygon on the screen. It has 10 vertices. So, to output those to the console I use this loop:
This works but I can't help but think there has to be a cleaner, more efficient way of accomplishing this task. A For Loop inside of a For Loop? One thing I think would help clean it up would be if I could just say "use that polygon" ... instead of looping through each Polygon (which right now isn't a problem because there is only one).Code:' loop through polygon and output the lat and lng for each of it's points Dim arrSys As System.Array Dim ienumSysColl As System.Collections.IEnumerator Dim intPointCount As Long Dim objLoc As MapPoint.Location Dim objShape As MapPoint.Shape For Each objShape In objMap.Shapes arrSys = objShape.Vertices ienumSysColl = arrSys.GetEnumerator intPointCount = UBound(objShape.Vertices) For i = 0 To intPointCount ienumSysColl.MoveNext() objLoc = ienumSysColl.Current Console.WriteLine("Point " & i & _ ": lat: " & objLoc.Latitude & _ " lng:" & objLoc.Longitude) Next Next
Is there a better, more efficient way of doing this? Please remember that I am very new to both VB 2005, OOP and Mappoint so if you can help please explain things to me like I'm 10 years old. Any and all help is greatly appreciated.