Select to view content in your preferred language

Assining featurelayer from map using C#

958
8
12-21-2010 02:05 AM
PiyushDubey
Emerging Contributor
Dear All,

          I have opened one Mapservices from arcgis server in arcgis explorer using c# code, but i am facing some problem when i assign servicelayer childitems or servicechildlayer item to featurelayer. after running the program it will show that null is asigned to featurelayer. If anyone have any idea pls let us know.

Thanks

Maximus
0 Kudos
8 Replies
AndreiIvanov
Deactivated User
You won't be able to do so. Can you explain what you are trying to achieve?
0 Kudos
PiyushDubey
Emerging Contributor
Andriy Ivanov ,

                      Actually i want to get the symbology attached with the layer i have opened using mapservices. i have gone through with the explorer object diagram, i think it is possible if i assign the target layer from mapdisplay as a featurelayer and get its renderer property. pls let me know in this reagrd if u have ny idea.

Thanks Maximus
0 Kudos
manasadevi
Emerging Contributor
Regarding, accessing FeaureLayer through c# code in arcExplorer, I am facing problem in implementing the code snippet which has given on ESRI resources @ http://resources.esri.com/help/900/arcgisexplorer/sdk/doc/49051a25-7752-415b-8925-06e8e83c1114.htm

which says:
[C#]

//Return the feature layer.
FeatureLayer campsitesLayer = Application.ActiveMapDisplay.Map.FindByName(
    "Campsites")as FeatureLayer;
//Return the renderer associated with the layer.
FeatureRenderer renderer = campsitesLayer.Renderer;
//Assign a new symbol to the layer.
renderer.SetSymbol(Symbol.Marker.Recreation.Camping);

When I give like,
FeatureLayer fl = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay.Map.FindByName(
    "Cities")as FeatureLayer;
nothing is being assigned to "fl" .. and "fl" remains null.

And in the code snippet, it is written like "Application.ActiveMapDisplay.Map.FindByName(
    "Campsites")as FeatureLayer;"
but without adding " ESRI.ArcGISExplorer.Application." in the front of the code given there, ambiguity error arises in my ArcExplorer.

Can anyone help with this problem.!!
0 Kudos
AndreiIvanov
Deactivated User
Andriy Ivanov ,

                      Actually i want to get the symbology attached with the layer i have opened using mapservices. i have gone through with the explorer object diagram, i think it is possible if i assign the target layer from mapdisplay as a featurelayer and get its renderer property. pls let me know in this reagrd if u have ny idea.

Thanks Maximus


You won't be able to get symbology off the mapservice via ArcGIS  Explorer SDK. To do so, you'd need access to ArcObjects, and request  symbol from ILegendClass within ILegendGroup.
0 Kudos
AndreiIvanov
Deactivated User
Regarding, accessing FeaureLayer through c# code in arcExplorer, I am facing problem in implementing the code snippet which has given on ESRI resources @ http://resources.esri.com/help/900/arcgisexplorer/sdk/doc/49051a25-7752-415b-8925-06e8e83c1114.htm

which says:
[C#]

//Return the feature layer.
FeatureLayer campsitesLayer = Application.ActiveMapDisplay.Map.FindByName(
    "Campsites")as FeatureLayer;
//Return the renderer associated with the layer.
FeatureRenderer renderer = campsitesLayer.Renderer;
//Assign a new symbol to the layer.
renderer.SetSymbol(Symbol.Marker.Recreation.Camping);

When I give like,
FeatureLayer fl = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay.Map.FindByName(
    "Cities")as FeatureLayer;
nothing is being assigned to "fl" .. and "fl" remains null.

And in the code snippet, it is written like "Application.ActiveMapDisplay.Map.FindByName(
    "Campsites")as FeatureLayer;"
but without adding " ESRI.ArcGISExplorer.Application." in the front of the code given there, ambiguity error arises in my ArcExplorer.

Can anyone help with this problem.!!


I successfully ran that code. Make sure your layer is "Cities" with capital C. It is case sensitive.
0 Kudos
PiyushDubey
Emerging Contributor
Andriy Ivanov ,

                     Sir u mean to say that i have to access arcobjects using server side programming. i have done arcobjects programming in arcmap using vba so i have knowledge of arcobjects but if u please elaborate more in this regard it will be helpful for me.

Thanks

Piyush
0 Kudos
AndreiIvanov
Deactivated User
Piyush,

all I am trying to say you won't be able to do it with ArcGIS Explorer. SDK does not expose symbol for ServiceChildLayer.
0 Kudos
PiyushDubey
Emerging Contributor
Andriy Ivanov,

                     Thanks for the information. ArcGIS Explorer does not expose mousemove and symbology, now in that case what options i have from ESRI so that i can do all these things in 3D. Pls let me know in this regards

Piyush
0 Kudos