Trouble with GetCenter()

2019
2
08-05-2010 12:28 PM
JoshuaPersson
New Contributor III
Hello-

...could anyone give any insight on how to use GetCenter() in VB to return the center of a polygon? I have created a Dock Window where the user can select a row in DataGridView and the selected polygon highlights with a new graphic. I would like to add a pop-up for the selected polygon, but I need the center point to tag the popup to which I am not having any luck in doing...

                     Thanks for your help

                       -Josh
0 Kudos
2 Replies
ShellyGill2
Occasional Contributor
how to use GetCenter() in VB to return the center of a polygon? [...] I need the center point to tag the popup to which I am not having any luck in doing...


Hi - it's pretty straightforward to do this - some code is below which you can try out in a Button - after the user tracks a Polygon on the map, a temporary Graphic will be added, with a Popup that has a Target which is the center of the Polygon.
Dim pgon As ESRI.ArcGISExplorer.Geometry.Polygon = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay.TrackPolygon()
Dim pt = pgon.GetCenter()

Dim disp As ESRI.ArcGISExplorer.Mapping.MapDisplay = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay
disp.Graphics.Add(New Graphic(pgon, Symbol.Fill.Solid.Blue, "Note"))

Dim tempPopup As Popup = New Popup(disp, Nothing, String.Format("Popup at {0},{1}", pt.X, pt.Y), "Note With Target", pt)
tempPopup.Activate()


You dont describe what kind of trouble you're having with GetCenter, but if the code above works for you, I'd suggest looking at the Polygon geometry that you're getting back from your DockWindow - check its a valid geometry, check IsEmpty. What do you actually get back from GetCenter - is it null, or a valid Point?
0 Kudos
JoshuaPersson
New Contributor III
Shelly-

...this worked wonderfully! I was calling the GetCenter() method incorrectly...thanks again!


                      -Josh
0 Kudos