display a new layer using ArcGIS Explorer SDK

491
1
08-14-2012 02:12 AM
Gyeong_MinRoh
New Contributor
Hello.

I'm trying to make an ArcGIS Explorer Add-In for internal use.
What's I wnat to do is to display a shapefile in current display when a user click a button.

I already tried the sample code from SDK help but nothing happens.

================================================================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;

using ESRI.ArcGISExplorer;
using ESRI.ArcGISExplorer.Application;
using ESRI.ArcGISExplorer.Mapping;
using ESRI.ArcGISExplorer.Geometry;
using ESRI.ArcGISExplorer.Data;
using ESRI.ArcGISExplorer.Threading;

namespace anakPetak
{
    public class anakPetakButton : ESRI.ArcGISExplorer.Application.Button
    {
        public override void OnClick()
        {
            //Create a DataSourceProperties object that holds the connection information to the feature class.
            DataSourceProperties featureLayerConnectionProps = new DataSourceProperties(@"C:\Korintiga\npa_tanam.shp");

            //Create a feature layer.
            FeatureLayer anakPetakFeatureLayer = new FeatureLayer(featureLayerConnectionProps);

            //Connect the layer to the feature class.
            bool connected = anakPetakFeatureLayer.Connect();

            //Add the layer to the map.
            if (connected)
            {

                ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay.Map.ChildItems.Add(anakPetakFeatureLayer);
                System.Diagnostics.Debug.Print("Test");
            }

            else
            {
                //Investigate connection issue.
                ConnectionStatus status = anakPetakFeatureLayer.ConnectionStatus;
                if (status.HasError)
                {
                    System.Diagnostics.Debug.Print(status.ErrorString);
                }
            }
        }
    }
}
==================================================================================

Would you please give an idea?

Many thanks.
0 Kudos
1 Reply
Gyeong_MinRoh
New Contributor
I already tested with file geodatabase format and it worked...
Doesn't the DataSourceProperties work with shapefile format?

Tks.
0 Kudos