ArcGIS Explorer SDK GalleryWalkThrough Sample

582
4
04-20-2010 11:53 AM
NickJacob
New Contributor II
I'm playing around with the ArcGIS Explorer SDK samples and can't get the GalleryWalkthrough Sample code to work (VisualBasic).  As I understand it the sample code is supposed to create an Add-In that will place a graphic of my choosing on the map after a mouse click.  I can see the Add-In in AGX but when I click on the map no graphic is displayed.  Is it possible that theres something in the sample code that doesn't work well with the new 1200 build?

Currently I'm using AGX 1200, ArcGIS Explorer SDK, and Visual Studio Express 2008.

Obviously I'm new to developing so any advice would be much appreciated!

Nick
Washington, D.C.
0 Kudos
4 Replies
NickJacob
New Contributor II
Replying to my own thread here...

Still can't fix the sample code mentioned previously, however I did find a helpful link to share for anyone who is interested.  It includes a little more sample code related to the Gallery I'm trying to build.

http://resources.esri.com/help/900/arcgisexplorer/sdk/html/97a4466c-60d2-bae0-d47a-ecb073399c5f.htm

--------------------
Nick
GIS Analyst
Washington, D.C.
0 Kudos
ShellyGill2
Occasional Contributor
Hi Nick,

I'm using this Gallery Walkthrough and find its working fine for me in 2D and 3D views, in Visual Studio Express 2008. Clicking the drop-down list in the gallery, choose the Gallery item with the Information symbol, and you will see the mouse cursor changes to a cross-hair when you hover over the map. Then click on the map somewhere, and you should see a 'ray' display effect indicating where you clicked, and the information symbol is added to the map. If you show the gallery, but dont select a gallery item, then when you click on the map you will not see any 'ray' feedback highlighting where you just clicked, and the mouse cursor remains as a hand, indicating the map is just navigating. Could this possibly be what happened?

If not, then ideally next you would debug the add-in - Visual Studio Express however does not offer out of the box functionality to debug DLLs within other EXEs, like you have with add-in projects. You can do the kind of 'debugging' where you show a lot of message boxes so you can see each line of code working - this would be worth a try - I have added some suggested things to check in the code below, taken from the Gallery class - recompile the add-in and give it another go.

Public Class Gallery
    Inherits ESRI.ArcGISExplorer.Application.Gallery

    'Use the ArcGIS_E3SDK environment variable here. It points to the install 
    'location of the ArcGIS Explorer developer kit, i.e. C:\Program Files\Explorer\DeveloperKit.
    Dim _strImage As String = Environment.GetEnvironmentVariable("ArcGIS_E3SDK") + "\\..\\Styles\\SymbolImages\\Points of Interest\\Information.png"

 Public Sub New()
  Dim envVar As String = Environment.GetEnvironmentVariable("ArcGIS_E3SDK")
  System.Windows.Forms.MessageBox.Show(String.Format("Check Environment Variable points to DeveloperKit location on disk: {0}", envVar))

  Dim btnImage As Image = Image.FromFile(_strImage)
  If (btnImage Is Nothing) Then
   System.Windows.Forms.MessageBox.Show("btnImage is Nothing")
  End If
  Dim myGalleryItem As GalleryItem = New GalleryItem("MyGalleryItem", btnImage, "Click on the map to add graphic")
  Me.Items.Add(myGalleryItem)
  If (Not Me.Items.Count = 1) Then
   System.Windows.Forms.MessageBox.Show("Did not find 1 GalleryItem")
  End If

 End Sub


 Public Overrides Sub OnClick(ByVal item As GalleryItem)

  Dim md As MapDisplay = Application.ActiveMapDisplay
  
  'Track the point on the map of the mouse click
  Dim trackPoint As ESRI.ArcGISExplorer.Geometry.Point = md.TrackPoint()
  If (trackPoint Is Nothing) Then
   System.Windows.Forms.MessageBox.Show("Tracked Point is nothing")
  ElseIf (trackPoint.IsEmpty) Then
   System.Windows.Forms.MessageBox.Show("Tracked Point has no geometry")
  End If

  'Turn the Point in to a Graphic
  Dim pointGraphic As Graphic = New Graphic(trackPoint)
  If (md Is Nothing) Then
   System.Windows.Forms.MessageBox.Show("New Graphic is nothing")
  End If

  'Set the Graphic's symbol to the same as the Gallery Image (Access the Symbol through Marker)
  pointGraphic.Symbol = Symbol.Marker.PointsOfInterest.Information
  If (pointGraphic.Symbol Is Nothing) Then
   System.Windows.Forms.MessageBox.Show("Graphic Symbol is nothing")
  End If

  'Add the graphic to the map
  md.Graphics.Add(pointGraphic)
  System.Windows.Forms.MessageBox.Show(String.Format("Number of graphics in map = {0}", md.Graphics.Count))

 End Sub


End Class
0 Kudos
NickJacob
New Contributor II
Thanks Shelly! 

The code provided was a big help.  Obviuosly I'm new to the developer side of things so providing code for me to look at goes a long ways.  I am a little curious as to why our code is so different.  Are the samples provided with a standard AGX SDK installation supposed to work right out of the box?  I'm copying in the code I'm working with from the GallyeryWalkthroughVB.sln file and it contains fewer lines.



Public Class Gallery
    Inherits ESRI.ArcGISExplorer.Application.Gallery

    'Use the ArcGIS_E3SDK environment variable here. It points to the install 
    'location of the ArcGIS Explorer developer kit, i.e. C:\Program Files\Explorer\DeveloperKit.
    Dim _strImage As String = Environment.GetEnvironmentVariable("ArcGIS_E3SDK") + "\\...\\Styles\\SymbolImages\\Points of Interest\\Information.png"



    Public Sub New()

        Dim btnImage As Image = Image.FromFile(_strImage)
        Dim myGalleryItem As GalleryItem = New GalleryItem("MyGalleryItem", btnImage, "Click on the map to add graphic")
        Me.Items.Add(myGalleryItem)

    End Sub


    Public Overrides Sub OnClick(ByVal item As GalleryItem)

        Dim md As MapDisplay = Application.ActiveMapDisplay
        'Track the point on the map of the mouse click
        Dim trackPoint As ESRI.ArcGISExplorer.Geometry.Point = md.TrackPoint()
        'Turn the Point in to a Graphic
        Dim pointGraphic As Graphic = New Graphic(trackPoint)
        'Set the Graphic's symbol to the same as the Gallery Image (Access the Symbol through Marker)
        pointGraphic.Symbol = Symbol.Marker.PointsOfInterest.Information
        'Add the graphic to the map
        md.Graphics.Add(pointGraphic)

    End Sub


End Class



Nick
Washington, D.C.
0 Kudos
ShellyGill2
Occasional Contributor
Yep, you have the sample as it's installed, I posted code where I had added additional lines so you can try and see if something is failing, as you have Express and not professional Visual Studio so debugging is not supported out of the box. So try my code instead and see if any of the message boxes give you a clue as to what's going wrong.
0 Kudos